git ignore files but only on the local repo

Naturally untracked files can be added to the .gitignore, and there are workarounds to update the history to remove files from tracking and .gitnore.

I had to update a config file, to include a setting that I only wanted on my machine. I did not want to be able to accidentally push the change to the origin, and I definitely did not want to have to continually manually edit/undo this file.

The solution was to:

git update-index --skip-worktree <file>

This will survive changing branches, hard resets etc. until such point as the --no-skip-worktree option is applied to revert the state.

Git - Difference Between ‘assume-unchanged’ and ‘skip-worktree’
I have local changes to a file that I don’t want to commit to my repository. It is a configuration file for building the application on a server, but I want to build locally with different settings.