with apologies

Ignoring changes

· 2 min read · March 23, 2026 · #dev #tech

OK, this one was mildly irritating but happily the solution is dead easy. In short, in this repo I have a file that I need to be committed as an empty file but then locally I want to have it be non-empty.1 And yet I also don’t want to continually be reminded of this by git as that might lead to me checking in the non-empty version by mistake.

Adding it to .gitignore would be the usual thing to do—but unfortunately, having ignored it I then had to forcibly add and commit the empty version:

touch FILENAME # create the file, empty
echo FILENAME >> .gitignore # ignore the file
git add -f FILENAME # add the ignored file
git commit -m "adding the empty ignored file" # yeah, exactly that

And that mean that git status and friends kept showing it as modified when I put back the non-empty content I want to keep locally:

...
# [edit and save the ignored FILENAME]
...
git status # now shows me FILENAME as modified even though it's ignored :(

What to do? Well, it turns out there’s a command for that:2

git update-index --assume-unchanged FILENAME
git status # no longer whines at me that FILENAME is modified :)

…and now the committed (empty) version remains unchanged, the local (non-empty) version is different, and git doesn’t keep trying to trick me into committing the changes to the ignored file. Happy days.

  1. It provides an index of all my tracks that I use locally but don’t want to publish.

  2. I suspect that, with git, there’s always a command for that. Even if it’s hard to find and harder yet to remember.