This is good for security so you can make a template file for security keys or whatever without commiting your own keys by accident.
First, set the file up how you want it to look in the repo:
touch <file>
subl3 <file>
enter the proper setup for the file
then commit the file to the repo:
git add <file>
git commit -m "added <file>"
use update-index to stop tracking the file:
git update-index --assume-unchanged <file>
Now you can put sensitive data in the file Changes will not be reflected in the index
If you need to make changes, copy the file with sensitive info. Put this somewhere else. you are about to overwrite it with the sanitized version tracked in the git repo -- you'll want to copy-paste its contents back in when you're done.
Checkout the HEAD file from the repo and set tracking back on :
git checkout <file>
git update-index --no-assume-unchanged <file>
Change the file accordingly, and commit changes. Then turn tracking back off with
git update-index --assume-unchanged <file>
and copy the file with sensitive data back in.