让git忽略vim在所有目录中生成的临时文件的正确方法是什么(无论是跨系统全局的还是单个项目的本地的)?
当前回答
在我的情况下,临时文件已经被之前的操作提交了,所以修改.gitignore不会影响那些提交的文件…,你必须git rm files_to_be_ignored——先缓存,然后提交,然后DONE。
其他回答
或者,您可以配置vim以将交换文件保存到单独的位置, 例如,在你的.vimrc文件中添加如下代码行:
set backupdir=$TEMP//
set directory=$TEMP//
有关更多信息,请参阅这个vim技巧。
# 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
肯定的是,
只需要创建一个“。Gitignore”在项目的主目录上 并且必须控制
*.swp
就是这样
在一个命令中
project-home-directory$ echo '*.swp' >> .gitignore
在我的情况下,临时文件已经被之前的操作提交了,所以修改.gitignore不会影响那些提交的文件…,你必须git rm files_to_be_ignored——先缓存,然后提交,然后DONE。
我发现这会让git忽略vim创建的临时文件:
[._]*.s[a-w][a-z]
[._]s[a-w][a-z]
*.un~
Session.vim
.netrwhist
*~
也可以在这里观看。
推荐文章
- 如何在vim中自动删除尾随空格
- 如何点Go模块的依赖在Go。Mod到回购中的最新提交?
- 为什么调用git分支——unset-upstream来修复?
- Windows git“警告:LF将被CRLF取代”,这是警告尾巴向后吗?
- git中的哈希冲突
- git可以自动在空格和制表符之间切换吗?
- 为什么Vim使用~扩展名保存文件?
- Git暂存文件列表
- 如何将git配置存储为存储库的一部分?
- 如何修改GitHub拉请求?
- 如何在Github和本地删除最后n次提交?
- 我如何调试git/git-shell相关的问题?
- 错误:无法使用rebase进行拉取:您有未分阶段的更改
- Git隐藏未缓存:如何把所有未分期的变化?
- 真实的恶魔