Every time I create a new git repo, I end up needing to create a new .gitignore file. Vim temp files keep showing up, begging to be put into the repository. It's like the gnats when you mow the lawn, you can ignore them for awhile, but then you just have to do something about it.
While working on the post "Better Git Commit Messages with Vim", I reviewed git customization 1 to ensure I had 'core.template' and 'core.editor' information correct. I ran across an option I don't remember seeing before, 'core.excludesfiles' 2. They address those very gnats as a super potent bug spray.
You can put patterns in your project’s .gitignore file to have Git not see them as untracked files or try to stage them when you run git add on them, as discussed in Ignoring Files.
But sometimes you want to ignore certain files for all repositories that you work with. If your computer is running Mac OS X, you’re probably familiar with .DS_Store files. If your preferred editor is Emacs or Vim, you know about filenames that end with a ~ or .swp.
What! How could I have missed this for so long?
Now, we can ignore not only vim recovery files, but those ever present Python cache files,
First, create a text file fille with out favorite, chronic problem files and name it
Now, add this to our global git config.with
and those pesky files won't bother me again.
This doesn't mean we won't need
.gitignore files anymore.
It just means during those first, exciting steps in repository creation, we will not be swatting away files.
It also means we have a great jumping off point when I do need to create a
and I am ready to get repo specific. Here is mine if you are interested.
*.swp __pycache__/ *.py[cod]