Austin Moore
Austin Moore

Reputation: 1412

Ignore files for commit but keeping them

I've got some 'resource files' that get changed every time we run our script. The files are located in a folder called 'res/'. Gathering the data the is in all these files takes a while, so I don't want to get rid of them every time I pull, however, I don't want to have to commit them whenever they change. I had them listed in a .gitignore but it seems that I loose them between creating new branches, merging branches back, and pulls.

How can I have git not remove them, but not keep track of them?

Upvotes: 0

Views: 49

Answers (1)

Chris Mantle
Chris Mantle

Reputation: 6693

You can use:

git update-index --assume-unchanged <file>

..to prevent Git from tracking changes to them. When you're done, you can use:

git update-index --no-assume-unchanged <file>

..to have Git track them again. I'm pretty certain this will prevent the files from being overwritten when git pull is used, but I'm not 100%.

Source: http://blog.pagebakers.nl/2009/01/29/git-ignoring-changes-in-tracked-files/

Upvotes: 1

Related Questions