让git忽略vim在所有目录中生成的临时文件的正确方法是什么(无论是跨系统全局的还是单个项目的本地的)?
当前回答
Vim临时文件以~结尾,因此可以在文件中添加.gitignore行
*~
Vim还创建了具有swp和swo扩展名的交换文件。要删除这些字符,请使用以下语句:
*.swp
*.swo
这将忽略单个项目中的所有vim临时文件
如果你想全局执行,你可以在家里创建一个.gitignore文件(你可以给它另一个名字或位置),并使用以下命令:
git config --global core.excludesfile ~/.gitignore
然后,您只需将想要忽略的文件添加到该文件中。
如果你想在Git文件中注释,你必须在单独的行中这样做:
# Ignore vim files:
*~
*.swp
*.swo
与活动git忽略放在同一行上的任何注释都将导致整行被错误解释。
其他回答
肯定的是,
只需要创建一个“。Gitignore”在项目的主目录上 并且必须控制
*.swp
就是这样
在一个命令中
project-home-directory$ echo '*.swp' >> .gitignore
如果您正在使用源代码控制。Vim临时文件非常无用。 因此,您可能希望配置vim不创建它们。
只需编辑您的~/。Vimrc并添加这些行:
set nobackup
set noswapfile
Vim临时文件以~结尾,因此可以在文件中添加.gitignore行
*~
Vim还创建了具有swp和swo扩展名的交换文件。要删除这些字符,请使用以下语句:
*.swp
*.swo
这将忽略单个项目中的所有vim临时文件
如果你想全局执行,你可以在家里创建一个.gitignore文件(你可以给它另一个名字或位置),并使用以下命令:
git config --global core.excludesfile ~/.gitignore
然后,您只需将想要忽略的文件添加到该文件中。
如果你想在Git文件中注释,你必须在单独的行中这样做:
# Ignore vim files:
*~
*.swp
*.swo
与活动git忽略放在同一行上的任何注释都将导致整行被错误解释。
我发现这会让git忽略vim创建的临时文件:
[._]*.s[a-w][a-z]
[._]s[a-w][a-z]
*.un~
Session.vim
.netrwhist
*~
也可以在这里观看。
# VIM: Temperory files
*~
# VIM: Swap-files
[._]*.s[a-w][a-z]
[._]s[a-w][a-z]
# VIM: Commands :cs, :ctags
tags
cscope.*
# VIM session
Session.vim
# VIM: netrw.vim: Network oriented reading, writing, browsing (eg: ftp scp)
.netrwhist
The name of the swap file is normally the same as the file you are editing, with the extension ".swp". On Unix, a '.' is prepended to swap file names in the same directory as the edited file. This avoids that the swap file shows up in a directory listing. On MS-DOS machines and when the 'shortname' option is on, any '.' in the original file name is replaced with '_'. If this file already exists (e.g., when you are recovering from a crash) a warning is given and another extension is used, ".swo", ".swn", etc. An existing file will never be overwritten. The swap file is deleted as soon as Vim stops editing the file. The replacement of '.' with '_' is done to avoid problems with MS-DOS compatible filesystems (e.g., crossdos, multidos).
http://vimdoc.sourceforge.net/htmldoc/recover.html
http://www.vim.org/scripts/script.php?script_id=1075
推荐文章
- 为什么我需要显式地推一个新分支?
- 如何撤消最后的git添加?
- Rubymine:如何让Git忽略Rubymine创建的.idea文件
- Gitignore二进制文件,没有扩展名
- Git隐藏错误:Git隐藏弹出并最终与合并冲突
- 在Vim中如何从“gf”返回
- 了解Git和GitHub的基础知识
- 没有。Git目录的Git克隆
- Git与Mercurial仓库的互操作性
- 忽略git中修改(但未提交)的文件?
- “git restore”命令是什么?“git restore”和“git reset”之间有什么区别?
- Git合并与强制覆盖
- Git拉另一个分支
- 在Bash命令提示符上添加git分支
- 如何更改Git日志日期格式