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)?
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:
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