问题描述
||
当我运行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忽略这些?在此先感谢您的帮助!
解决方法
.*.m.swp
应该可以工作:我已经在我的msysgit1.7.4环境中对其进行了测试。
因此:不是\“*...
\”,而是\“.*...
\”。
别忘了在新的git status
之前将修改后的ѭ4add添加到索引中。
,.*\\\\.m\\\\.swp
而是这样做,因为未转义的。\可以匹配任何内容