TL;DR; Ignore a tracked file in Git without removing it

So the other day when I was organizing my Dotfiles, I wanted to ignore some files with .gitignore however since it was tracked, it was not ignoring the files. (I want to file exists in Remote but I don’t want to push changes because it contains sensetive data).

Found a neat way to do it:

  • This command will manually ignore the changes:
git update-index --assume-unchanged <file>
  • If you want to start tracking changes again:
git update-index --no-assume-unchanged <file>


Greetings! 🌟 Berkcan here, your friendly neighborhood Full Stack Developer. I have a passion for discovering and tinkering with bleeding-edge tech.

While there are other ways to ignore a file via Git you may want to ignore a file that you have already checked in. This post shows you how to ignore a file and not remove it.