I often find myself commiting with git add -f binary files which are in .gitignore (.exe, .pdf, ...), just to include a stable, working, compiled file in the history, so I can at least use it even if I have problems compiling it again (eg. because of a missing library on another computer).
$ 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 Now that I've added the .exe and .pdf, I'd like that future modifications to them be ignored. Otherwise, each time I do git commit -a these files are automatically included.