Git Ignore Changes to a File

To tell Git to ignore changes to a file, set the skip worktree option.

git update-index --skip-worktree filename

This will fail loudly when something inevitably go wrong and the file gets changed in an incompatible way, one way or another.

Then you can undo it:

git update-index --no-skip-worktree <file>
git add -p <file>
git update-index --skip-worktree <file>

Found here.