git ignore vim temporary files

jrdioko picture jrdioko · Jan 28, 2011 · Viewed 115.6k times · Source

What is the correct way to make git ignore temporary files produced by vim in all directories (either globally across the system or locally for a single project)?

Answer

nunopolonia picture nunopolonia · Jan 28, 2011

Vim temporary files end with ~ so you can add to the file .gitignore the line

*~

Vim also creates swap files that have the swp and swo extensions. to remove those use the lines:

*.swp
*.swo

This will ignore all the vim temporary files in a single project

If you want to do it globally, you can create a .gitignore file in your home (you can give it other name or location), and use the following command:

git config --global core.excludesfile ~/.gitignore

Then you just need to add the files you want to ignore to that file