【问题标题】:.gitignore and untracked files are shown in git status.gitignore 和未跟踪的文件显示在 git status 中
【发布时间】:2019-10-30 00:49:12
【问题描述】:

我在使用 git 1.8.3.1 的 Centos 7.5.1804 上遇到了奇怪的情况。 我有.gitignore

*.pyc

git status 显示关注

$ git status
# On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   a.pyc
#   b.pyc
#   c.pyc
#   d.pyc

此外,这些文件从未提交过。所以 git status 不应该显示这些文件。什么可能导致这种情况发生?

【问题讨论】:

  • 与这些文件相关的 gitignore 文件在哪里?
  • git目录根目录下的所有文件。
  • 这很奇怪。我无法复制这个......我正在使用centos 7.5.1804(docker image),git-x86-64 1.8.3.1-20.el7。你能确保 gitignore 文件中 *.pyc 周围没有空格吗?
  • @evolutionxbox 太棒了。你说的对。这只是由于空白。但是,我在 Ubuntu 16.04.5 和 git 2.7.4 中使用相同的文件,但没有显示这些文件。所以我很困惑。
  • 太棒了!很高兴您发现了问题。

标签: git gitignore git-status git-untracked


【解决方案1】:

这是由于 .gitignore 文件中的拼写错误,在 *.pyc 之后有多余的空间。但是,Ubuntu 16.04.5git 2.7.4 的行为不同,即使有额外的空间,文件也没有列出。

git 1.8.3.12.7.4 之间可能已经解决了这个空间问题。

【讨论】:

  • 请注意current documentation 提到它:Trailing spaces are ignored unless they are quoted with backslash ("\").
猜你喜欢
  • 2011-06-04
  • 1970-01-01
  • 2013-04-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-02-24
  • 2015-12-04
相关资源
最近更新 更多