You'll generally find that adding each and every file one by one can become tedious when your project becomes bigger.
In Java, you may end up with many .class
files that you wouldn't want to add to your repository. Similarly, you may end up with many .o
files in C, or .pyc
in Python (for example).
Having patterns like *.class
, *.o
, *.pyc
in your .gitignore
files allows you to ignore those files once and for all. Subsequent git status
runs (or similar if you're using a GUI) will not tell you these are new, untracked files, thereby letting you focus on the files that are really new and noticeably untracked.
This can also be useful if you add an entire directory (e.g. git add myproject
): this lets you ignore a category of files altogether.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…