Pages

Thursday, March 27, 2014

How to make git stop ignoring your gitignore

When you find that git is ignoring the pattern of specific files in your .gitignore or .git/info/exclude, then it is very likely that the file(s) in question have already been (--force) committed by someone.

Sometimes you just want to ignore changes to your IDE, for instance eclipse project files e.g. .classpath, project.properties, .project. This is what you should do to stop git ignoring your intention to ignore changes to certain files.

  1. git update-index --assume-unchanged {filename}
  2. echo {filename} >> .git/info/exclude

Step 1. serves to make git stop ignoring your intentions with some {filename}.

Step 2. serves to make locally ignore these files in your own repository, i.e. this ignore directive will not be shared with other people.

Use .gitignore instead of .git/info/exclude in the root of your repository in Step 2. if you want to share this with everybody who has a clone of your repository. Don't forget to add and commit the .gitignore file.