A project I am working on has a configuration file that contains a few variables for using Microsoft’s Active Directory to authenticate to a Ruby on Rails application. This is working great, but I was banging my head against a wall trying to get Git to not track changes to the configuration file. I didn’t want my username and passwords tracked in GitHub for obvious reasons, but I did want a generic copy of the configuration file in the repository.
While searching for a solution today, I ran across this little gem of an article titled “GIT: ignoring changes in tracked files” from Pagebakers.nl, the salient code is below:
git update-index --assume-unchanged <file>