【问题标题】:Strange .gitignore behavior for emacs temporary filesemacs 临时文件的奇怪 .gitignore 行为
【发布时间】: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 按我的意愿工作吗?非常感谢!

【问题讨论】:

    标签: git emacs


    【解决方案1】:

    .gitignore 文件上的注释必须在自己的行中 - 文件模式后面的任何注释都被解释为该模式的一部分。

    将您的 cmets 移动到模式之前的行,它应该返回到它的初始行为。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多