git 忽略 vim 临时文件 [英] git ignore vim temporary files
问题描述
让 git 忽略所有目录中 vim 生成的临时文件的正确方法是什么(无论是整个系统的全局文件还是单个项目的本地文件)?
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 临时文件以 ~ 结尾,所以你可以在文件中添加 .gitignore
行
Vim temporary files end with ~ so you can add to the file .gitignore
the line
*~
Vim 还创建具有 swp 和 swo 扩展名的交换文件.删除那些使用行:
Vim also creates swap files that have the swp and swo extensions. to remove those use the lines:
*.swp
*.swo
这将忽略单个项目中的所有 vim 临时文件
This will ignore all the vim temporary files in a single project
如果你想全局做,你可以在你的家中创建一个.gitignore文件(你可以给它其他名字或位置),并使用以下命令:
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
这篇关于git 忽略 vim 临时文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!