簡體   English   中英

.gitignore並沒有忽略我的vim臨時文件

[英].gitignore is not ignoring my vim temporary files

我的.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??

以下是應該保持跟蹤的文件

# 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。 並提交推送,這些文件重新添加。 任何幫助都會很棒。

使用標准規則

對於忽略規則github上一個方便的存儲庫 ,對於Vim,規則是

# swap
[._]*.s[a-w][a-z]
[._]s[a-w][a-z]
# session
Session.vim
# temporary
.netrwhist
*~
# auto-generated tag files
tags

使用這樣的規則的最佳方法是將它們放在全局git ignore文件中

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/

通過這種方式,vim不會使用文件污染您的工作副本,忽略與否=)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM