【发布时间】:2012-07-14 22:21:49
【问题描述】:
如果我用 emacs 编辑new_file.txt,当文件未保存时会有#new_file.txt# 和.#new_file.txt 之类的临时文件,保存时会出现new_file.txt~。
我想排除这些文件。所以我这样写我的.gitignore:
#This is a comment line
*~
[#]*[#]
.\#*
这很完美。但后来我添加了一些注释行:
#This is a comment line
*~
[#]*[#] # this is a comment
.\#* # this is another comment
在git status 之后,我看到#new_file.txt# 和.#new_file.txt 都被列为未跟踪文件。
我认为.gitignore 可能会对# 字符作为注释行的开头感到困惑。所以我删除了这两条注释行。但是,在另一个git status 之后,我仍然看到#new_file.txt# 和.#new_file.txt 被列为未跟踪文件。
我愿意:
git rm -r --cached .
正如".gitignore not working" 中所建议的那样,但这并没有帮助。
有人可以告诉我发生了什么,以及如何让.gitignore 按我的意愿工作吗?非常感谢!
【问题讨论】: