Assume Unchanged

Situation:

  1. Cut git branch
  2. While I’m on this branch, I need to change a few lines in config-blah-blah.yaml for a very particular reason. Say, a change in database credentials to connect to a database specific to testing the changes on this branch.
  3. Changes to that config file are very temporary and should not go back to the main branch. Fine fine fine, but it’s 😤 annoying that it’ll sit there as a changed file begging to be accidentally swallowed up by a git add .
  4. Solution! git update-index --assume-unchanged "config-blah-blah.yaml" 😍

Isn’t that what .gitignore is for? Kinda, except that if I change the .gitignore file to ignore the file on this branch, the change to .gitignore risks going back to main, which would be an even bigger problem than the config file going to main. Not useful here. The “assume unchanged” situation is way cleaner.

Shout out to Nate Roling who pointed me to a blog post by Nick Raphael that had the answer.

Leave a Reply

Your email address will not be published.