I’m working with a git repository that’s storing data for a website. It contains a .htaccess file, with some values that are suitable for the production server. In order for me to work on the site, I have to change some values in the file, but I never want to commit these changes or I will break the server.
Since .gitignore doesn’t work for tracked files, I was using “git update-index –assume-unchanged .htaccess” to ignore my changes in the file, however this only works until you switch branches. Once you change back to your original branch, your changes are lost.
Is there some way of telling git to ignore changes in a file and leave it alone when changing branches? (Just as if the file was untracked.)
You could use a smudge/clean process (a gitattribute filter driver, described in ProGit)
Each time you update your working directory, you would have the opportunity to replace the content of your
.htaccesswith a predefined one, correct for your current environment.In the clean stage, you would then restore the original content, as if you had never touched that file.