有没有办法告诉 git-status 忽略 .gitignore 文件的影响?
我配置了许多 .gitignore
文件,从一组大约 6,000 个未跟踪的文件中过滤掉许多不同的不需要的文件。当我的过滤列表看起来像我想要的那样时,我想做 git add . 。
但是,然后我想暂时禁用 .gitignore 过滤器以查看留下的内容,并确保没有任何重要的意外过滤。
我知道 git-clean 包含一个忽略 .gitignore 文件的选项。 git-status 是否有类似的选项?
我可以检查并删除所有 .gitignore 文件,进行检查,然后恢复它们,但似乎应该有更简单的方法?
I have configured numerous .gitignore
files to filter out many different unwanted files from a set of about 6,000 untracked files. I want to do git add .
when I've got my filtered list looking the way I want it.
But, then I want to disable the .gitignore
filters temporarily to see what got left behind, and make sure there was nothing important accidentally filtered.
I know that git-clean
includes an option to ignore .gitignore files
. Is there a similar option for git-status
?
I could go through and delete all the .gitignore
files, do the check, then restore them, but it seems there should be an easier way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这个选项
--ignored
可以解决问题:(更新 1)我发现
--ignored
选项单独在某些 git 安装中不起作用,也许这是一个 git bug。在这些情况下,额外的-s
对我有用:(更新 2)
一位用户报告 git 版本 1.7.0.4 不支持
--ignored
选项。我的git版本是1.7.6。另一个版本 1.7.5.1 是需要-s
的版本。您可以尝试查看是否支持
--ignored
。This option
--ignored
does the trick:(Update 1) I found the
--ignored
option alone doesn't work in certain git installations, perhaps it's a git bug. In those cases, an additional-s
works for me:(Update 2)
One user reported
--ignored
option is not supported in git version 1.7.0.4. My git version is 1.7.6. Another version 1.7.5.1 is the one that requires-s
. You may tryto see if
--ignored
is supported.尝试使用 git ls-files --other - 它应该列出 git 不知道的所有文件;即那些不在存储库中且不会被
.gitignore
忽略的文件。您还可以使用 git ls-files --ignored --exclude-standard 来查看 git 显式忽略的文件。
Try using
git ls-files --other
- it should list all files that git doesn't know about; i.e. those files that aren't in the repository and aren't ignored by.gitignore
.You can also use
git ls-files --ignored --exclude-standard
to see what files git is explicitly ignoring.git clean -dXn
请参阅:Git 命令显示哪个.gitignore 忽略特定文件
事实上,这个问题似乎是重复的!
git clean -dXn
See: Git command to show which specific files are ignored by .gitignore
In fact this question seems to be a duplicate!