6

When I run git status, it lists a bunch of .gitignore files that I am not interested in seeing in the list (they got updated locally by Eclipse). I browsed numerous posts in regards to this seemingly common issue but none of the suggested solutions worked for me.

E.g. I went into ~/.gitconfig and found that

excludesfile = ~/.gitignore_global

Then I went into that file and added .gitignore at the tail but that did not change anything.

How do I effectively ignore .gitignore files in git status so they don't clutter the view?

4

5 回答 5

12

听起来您可能误解了“忽略”对 Git 的含义。中提到的文件名.gitignore意味着如果文件未跟踪,则git status不会将该文件显示为未跟踪文件。

当文件被 Git 跟踪并被修改时,忽略文件不会做任何事情。这被认为是对您的存储库的更改,Git 不允许您忽略它。(毕竟,你已经告诉 Git 该文件足够重要,可以存储在你的存储库中,因此 Git 有义务通知你该文件的更改。)

如果您的工具(Eclipse)正在修改您的.gitignore文件,我建议您指示 Eclipse 停止这样做。

于 2013-09-04T03:45:04.207 回答
4

尝试:

git status --ignored

来自man git-status

--ignored 也显示被忽略的文件。

于 2015-02-10T21:58:11.883 回答
1

只需将条目 '.gitignore' 添加到 .gitignore 文件中。然后 'git status' 不会将 .gitignore 显示为未跟踪的文件之一。如果您不想在源代码管理中包含 .gitignore,这可能会有所帮助。

于 2017-06-04T19:18:52.607 回答
0

看看你的 git 版本是否支持 untracked 选项。例如:

git status --untracked-files=no

于 2014-09-07T15:40:36.990 回答
0

你可以,

Git 忽略在内部用于设置忽略。

你不能忽略忽略设置文件,这是一个奇怪的行为

于 2013-09-03T22:26:54.210 回答