Today I learned how to untrack files that have already been added to a git repository. The following command will stop tracking but keep the file there intact. This is good for directories that have auto generated files every so often so everytime you do a git commit, you don’t have to commit a new copy of these files.
git rm --cached filename
The rm made me nervous because I didn’t want to accidentally remove my file ( made a backup before I did it). Good thing it all worked out and now git doesn’t have to do any unnecessary tracking.
== update ==
Just likes James mentions in the comments, you can use .gitignore as your next step.
== update 7/7/2011 ==
git update-index --assume-unchanged [path]
seems like a much better solution than rm –cached in a collaborative environment. My use cases have always been working on my own stuff by myself so I can’t argue against that point. This was a new command to me so I messed around with it for a little bit with a test repository and noticed some differences:
- I can still checkout the file from the repository since it’s only ignored.
git update-index --no-assume-unchanged filenamewill bring it back into the mix to be tracked.
- I couldn’t find a way to see what files were “assumed-unchanged” through git or in the .git folder.
Your mileage may vary, but I think I will start using the git update-index –assume-unchanged in the future. Thanks for all the comments and help.