你如何 git 显示 .gitignore 中不存在的未跟踪文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3538144/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do you git show untracked files that do not exist in .gitignore
提问by justjoe
I'm using git status -u
to show untracked files. And on the terminal, I see plenty untracked files that I need to be untracked such as unit tests, personal documentation, etc. I have put them in .gitignore
, but it seems that git status
still shows them.
我git status -u
用来显示未跟踪的文件。在终端上,我看到很多我需要取消跟踪的未跟踪文件,例如单元测试、个人文档等。我已将它们放入 . 中.gitignore
,但似乎git status
仍然显示它们。
How do you show only untracked files that don't exist in .gitignore
.
您如何仅显示.gitignore
.
回答by Matthew McCullough
You can explicitly list what is being tracked and untracked as follows to see if Git is seeing and honoring your .gitignore
. If you post your .gitignore
contents, git status
output, and dir
or ls
we can better assist you.
您可以如下明确列出正在跟踪和未跟踪的内容,以查看 Git 是否正在查看并尊重您的.gitignore
. 如果您发布您的.gitignore
内容、git status
输出和/dir
或ls
我们可以更好地为您提供帮助。
List ignored files
列出被忽略的文件
$ git ls-files . --ignored --exclude-standard --others
List untracked files
列出未跟踪的文件
$ git ls-files . --exclude-standard --others
回答by Brooks Folk
git update-index --no-assume-unchanged <file>
回答by Ohad Sadan
Use:
用:
git config status.showuntrackedfiles no