Question:
How can I ignore .pyc
files in git?
If I put it in .gitignore
it doesn’t work. I need them to be untracked and not checked for commits.
Answer:
Put it in .gitignore
. But from the gitignore(5)
man page:
123456789101112 · If the pattern does not contain a slash /, git treats it as a shellglob pattern and checks for a match against the pathname relativeto the location of the .gitignore file (relative to the toplevel ofthe work tree if not from a .gitignore file).· Otherwise, git treats the pattern as a shell glob suitable forconsumption by fnmatch(3) with the FNM_PATHNAME flag: wildcards inthe pattern will not match a / in the pathname. For example,"Documentation/*.html" matches "Documentation/git.html" but not"Documentation/ppc/ppc.html" or"tools/perf/Documentation/perf.html".
So, either specify the full path to the appropriate *.pyc
entry, or put it in a .gitignore
file in any of the directories leading from the repository root (inclusive).