你如何 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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 08:56:18  来源:igfitidea点击:

How do you git show untracked files that do not exist in .gitignore

git

提问by justjoe

I'm using git status -uto 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 statusstill 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 .gitignorecontents, git statusoutput, and diror lswe can better assist you.

您可以如下明确列出正在跟踪和未跟踪的内容,以查看 Git 是否正在查看并尊重您的.gitignore. 如果您发布您的.gitignore内容、git status输出和/dirls我们可以更好地为您提供帮助。

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