.gitignore没有忽略我的vim临时文件
我的.gitignore文件有问题。我做了研究,尝试了很多方法。当我保存.gitignore时,将执行以下步骤.gitignore没有忽略我的vim临时文件,git,vim,Git,Vim,我的.gitignore文件有问题。我做了研究,尝试了很多方法。当我保存.gitignore时,将执行以下步骤 git rm -rf --cached *.php.* git add . git status git commmit -m "some message" 下面是我的.gitignore文件的外观: # Ignores anything that's a temp file created by vim .*.s?? .*.*.s?? 以下是它应该避免被跟踪的文件 # Untra
git rm -rf --cached *.php.*
git add .
git status
git commmit -m "some message"
下面是我的.gitignore文件的外观:
# Ignores anything that's a temp file created by vim
.*.s??
.*.*.s??
以下是它应该避免被跟踪的文件
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# .ajax.php.swn
# .ajax.php.swo
# .ajax.php.swp
# .swervepay.php.swn
# .swervepay.php.swo
# .swervepay.php.swp
# .swervepay_form.php.swm
# .swervepay_form.php.swn
# .swervepay_form.php.swp
#未跟踪的文件:
#(使用“git add…”包含在将提交的内容中)
#
#.ajax.php.swn
#.ajax.php.swo
#.ajax.php.swp
#.swervepay.php.swn
#.swervepay.php.swo
#.swervepay.php.swp
#.swervepay_form.php.swm
#.swervepay_form.php.swn
#.swervepay_form.php.swp
我能做些什么来防止这些文件被跟踪?每次我做一个git添加。并承诺向上推,这些文件将被重新添加。任何帮助都将是巨大的。使用标准规则
这是因为:
使用此类规则的最佳方法是:
或者将交换文件放在其他地方
但是,这样做可能更好:
" ~/.vimrc file
" swap files (.swp) in a common location
" // means use the file's full path
set dir=~/.vim/_swap//
" backup files (~) in a common location if possible
set backup
set backupdir=~/.vim/_backup/,~/tmp,.
" turn on undo files, put them in a common location
set undofile
set undodir=~/.vim/_undo/
这样,vim就不会用文件污染您的工作副本,不管是否被忽略=)。我不知道您的配置有什么问题,但即使是一个简单的
*.sw?
也应该可以工作(不需要前导点)。可能.gitignore
位于错误的位置。当我添加完整文件名时,.gitignore将起作用,因此不是因为它位于错误的位置。如果我把文件名全部列出来就行了。我刚刚创建了一个全局文件,并从目录中删除了sw*文件。希望在提交之后,如果添加了任何内容,它都会被忽略。我接受这个建议,因为从该目录中删除临时文件通常会有所帮助。谢谢如何检查全局配置是否正常工作?git status
仍然显示临时文件(以波浪号结尾)。@Carcamano如果您指的是标准git ignore文件-如果您看到这些条目它不起作用,请按照以下内容进行调查:您没有加载~/.gitinore
。如果您指的是vim配置,那么更改配置不会删除现有的swap/tmp文件。
git config --global core.excludesfile ~/.gitignore
" ~/.vimrc file
" swap files (.swp) in a common location
" // means use the file's full path
set dir=~/.vim/_swap//
" backup files (~) in a common location if possible
set backup
set backupdir=~/.vim/_backup/,~/tmp,.
" turn on undo files, put them in a common location
set undofile
set undodir=~/.vim/_undo/