Ignoring file changes with git

Here’s a quick little post about one of the most useful tricks you can do with git. Often you have files you are working with in a project that you need to track the file for everyone on the project to have but not save your changes to the file itself. For example, project files in eclipse that change how the project uses the files. To have the file in the index but not save the changes, do the following.

do a

git add

do a

git commit

do a

git update-index --assume-unchanged [FilePath]

Now the file you have told git that any changes you make to the file, it can ignore. There are a couple more notes you might want to know.

To stop ignoring changes to the file you can call git update-index –no-assume-unchanged

If someone else changes the file in a merge, even if they change it back, you’ll have to tell git to ignore it again.

Egit, the eclipse git plugin, has this functionality under the advanced section of the team menu.

Rebasing always seems to require me to remind git to ignore changes.

This has been a great help for files at work. Actionscript project files like .actionscriptproperties, .project and a developer config file are important to have tracked but helpful to allow untracked changes.