Suzanne Soy
Suzanne Soy

Reputation: 3244

Ignore future modifications of a .gitignore'd file which was added with git add -f

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.

Upvotes: 2

Views: 246

Answers (2)

kan
kan

Reputation: 28951

There is no point to store binaries in a same repo as source code, as it will create problems - rapidly growing repo size, problem during merges, slower operations. The better if you create another repo and store files with versions. It is called binary repository. You even don't need have a proper VCS repo, just a set of folders named after version number, e.g. http://download.cdn.mozilla.net/pub/mozilla.org/firefox/releases/

Another option is to use git notes. In a man-page you could find a way to attach any binary file to any object in the repo.

Upvotes: 2

Atropo
Atropo

Reputation: 12531

You can use the --assume-unchanged option here the manpage.

git update-index --assume-unchanged program.exe documentation.pdf

In this way those files aren't added to the index.

Upvotes: 5

Related Questions