当我运行git status时,*.m.swp
文件显示在“untracked list
”中,因为我目前在MacVim中打开了这些文件(原件是带有*.m
文件扩展名的MATLAB文件)。
我已尝试将*.m.swp
及其各种排列添加到我的.gitignore
文件中,以便忽略这些文件,但似乎没有任何内容对我有效。
请参阅下面的git status输出示例:
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
我如何让git忽略这些?在此先感谢您的帮助!
答案 0 :(得分:2)
.*.m.swp
应该可以工作:我已经在我的msysgit1.7.4环境中测试了它
所以:不是“*...
”而是“.*...
”。
在执行新的.gitignore
之前,请不要忘记将修改后的git status
添加到索引中。
答案 1 :(得分:0)
.*\\.m\\.swp
这样做,因为未转义。匹配任何东西