文件掩码以排除git中的* .m.swp文件

问题描述

|| 当我运行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
而是这样做,因为未转义的。\可以匹配任何内容     

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...