Keep file in a Git repo, but don't track changes
git has a different solution to do this. First change the file you do not want to be tracked and use the following command:
git update-index --assume-unchanged FILE_NAME
and if you want to track the changes again use this command:
git update-index --no-assume-unchanged FILE_NAME
git-update-index documentation
To pull an answer out of the comments of another answer:
$ git update-index --skip-worktree FILENAME
Appears to be a better option than --assume-unchanged
More can be read about this here: Git - Difference Between 'assume-unchanged' and 'skip-worktree'
For my Code Igniter projects, I keep database.php.example and config.php.example in the repo.
Then I add config.php and applications/config/database.php to the .gitignore file.
So, finally, when I deploy, I can copy the .example files (to config.php and database.php), customize them, and they won't get tracked by GIT.