Ignoring files in git without cluttering up history

If you are like me, you have a couple scratch files lying around in your repository. They don't have anything to do with the project and aren't relevant to the other members of my team, so I don't want to add them to .gitignore.

The usual outcome of this is selectively committing and trying to avoid checking in these extraneous files. However, I recently learned that there is a git configuration file called .git/info/exclude you can modify to ignore files. It's like .gitignore, but not checked in.

Here's an example:

# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~
scratch.rb
migration-problems.txt
.ruby-gemset

This is mentioned in the gitignore documentation and with more context by GitHub.