2011-04-14 20 views
1

當我運行git狀態時,*.m.swp文件出現在「untracked list」中,因爲我目前在MacVim中打開了這些文件(原始文件是帶有*.m文件擴展名的MATLAB文件)。
我已經嘗試添加*.m.swp和這個的各種排列,我的.gitignore文件,以便文件被忽略,但似乎沒有爲我工作。
請參見下面的git狀態輸出的例子:文件掩碼以排除git中的* .m.swp文件

git status 
# On branch mybranch1 
# Changes to be committed: 
# (use "git reset HEAD <file>..." to unstage) 
# 
# modified: ../dir1/file1.m 
# new file: file2.m 
# new file: file3.m 
# modified: file4.m 
# 
# Untracked files: 
# (use "git add <file>..." to include in what will be committed) 
# 
# ../../dir2/.file5.m.swp 
# ../dir1/.file6.m.swp 
# ../dir1/.file1.m.swp 
# ../dir1/.file7.m.swp 
# ../dir1/.file8.swp 
# .file9.m.swp 
# .file4.m.swp 

我怎樣才能得到混帳忽略這些?預先感謝任何幫助!

回答

2
.*.m.swp 

應該工作:我測試了它在我的msysgit1.7.4環境中。
因此:不是「*...」而是「.*...」。

在做新的git status之前,不要忘記將修改後的.gitignore添加到索引中。

+0

感謝@VonC!我不認爲我在運行'git status'之前添加了'.gitignore'。我現在在我的全球忽視中。 – Abbie 2011-04-18 17:56:08

+0

@Abbie:優秀:)我把它'.gitignore'現在工作? – VonC 2011-04-18 18:39:15

0
.*\\.m\\.swp 

做到這一點,而不是因爲的轉義。比賽什麼

+0

您不需要在.gitignore中轉義點 – 2012-11-08 17:51:13