I occasionally run into a situation with Git where I have modified a file but have no intention of committing the change to the repository. This most often happens with computer specific configuration files. My
config/database.yml in Rails projects can spend a lot of time in a dirty state if one of my dev machines has a root mysql password and the other does not.
Git will ignore untracked files that are added to
.gitignore files or the
.git/info/exclude file. For files that git knows about and is already tracking there is a obscure way to tell git to ignore changes to those files.
git update-index --assume-unchanged config/database.yml
When you have made changes to the file that you want to commit you’ll need to execute the inverse (
--no-assume-unchanged) for git to acknowledge that the file has changed.