如果我编辑new_file.txt使用Emacs,会出现类似的临时文件#new_file.txt#,并.#new_file.txt在文件未保存,并且new_file.txt~在保存时.我想要排除这些文件.所以我这样写.gitignore:
#This is a comment line
*~
[#]*[#]
.\#*
Run Code Online (Sandbox Code Playgroud)
这完美无缺.但后来我添加了一些注释行:
#This is a comment line
*~
[#]*[#] # this is a comment
.\#* # this is another comment
Run Code Online (Sandbox Code Playgroud)
之后git status,我看到两者#new_file.txt#并被.#new_file.txt列为未跟踪文件.
我认为.gitignore可能会将#角色作为评论行的开头而感到困惑.所以我删除了这两个注释行.然而,层出不穷git status,我仍然看到 #new_file.txt#并.#new_file.txt为未跟踪文件中列出.
我做 :
git rm -r --cached .
Run Code Online (Sandbox Code Playgroud)
正如".gitignore not working"所述,但它没有帮助.
有人可以告诉我发生了什么,以及如何.gitignore按我的意愿工作?非常感谢你!