In this example a CodeIgniter app, where the database config file was hard-coded and needed to be ignored from the future commits.
The simplest way to deal with that is : git update-index --assume-unchanged
method.
Command line:
git update-index --assume-unchanged path/to/file
Confirm it worked
git ls-files -v | grep ^h
Restore git staging
git update-index --no-assume-unchanged path/to/file