Add the following line to the .gitignore file in the root folder of your git repository tree right after repository initialization.:
*.pyc
Also, in case you forgot to do it beforehand, and you just add the line to the .gitignore file, all previously committed .pyc files will still be tracked, so you'll need to remove them from the repository.
Say, you are on a Linux system (or "parents&sons" like a MacOSX), you can quickly do it with just this one line command that you need to execute from the root of the repository:
find . -name "*.pyc" -exec git rm -f "{}" \;
It means starting from the directory I am currently in, find all files whose name ends with extension .pyc, and pass file name to the command git rm -f
After *.pyc files deletion from git as tracked files, commit this change to the repository, and then you can finally add the *.pyc line to the .gitignore file.