我经常发现自己使用git add -f
.gitignore ( .exe
, .pdf
, ...) 中的二进制文件提交,只是为了在历史记录中包含一个稳定的、工作的、编译的文件,所以即使我再次编译时遇到问题,我至少可以使用它(例如,因为另一台计算机上缺少库)。
$ cat .gitignore
*.exe
*.pdf
$ git add -f program.exe documentation.pdf
$ git commit -m "Added working .exe and .pdf"
$ gcc program.c -o program.exe
$ pdflatex documentation.tex # Generates documentation.pdf
$ git status --short
M program.exe
M documentation.pdf
现在我已经添加了.exe
and .pdf
,我希望将来对它们的修改被忽略。否则,每次我执行git commit -a
这些文件时都会自动包含在内。