Quite often, I find myself in the situation where I've updated a file but I don't want git to track that change. Usually this is a temporary update to a config file.
For example, right now I'm running my webapi locally and I've updated my angular environment.ts file to point locally. I'll be working like this for a few days and I want to regularly commit and push my changes. But I don't want to commit the changes to environment.ts. I like to do git add . to include all my updates but it's annoying to have a single file that I don't want to include.
Turns out, unsurprisingly, there is a handy git command for this...
git update-index --assume-unchanged "somewhere/environment.ts"
If you run a git status you will see that git is no longer aware of the edit. We can now do...
git add .
git commit -m "I did stuff and stuff"
To undo this, we simply...
git update-index --no-assume-unchanged "somewhere/environment.ts"
I do this whenever I make an update that I know I won't want to push.