有没有办法告诉 git-status 忽略 .gitignore 文件的影响?

发布于 2024-09-04 15:50:12 字数 296 浏览 4 评论 0原文

我配置了许多 .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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

剪不断理还乱 2024-09-11 15:50:12

这个选项--ignored可以解决问题:

git status --ignored

(更新 1)我发现 --ignored 选项单独在某些 git 安装中不起作用,也许这是一个 git bug。在这些情况下,额外的 -s 对我有用:(

git status -s --ignored

更新 2)
一位用户报告 git 版本 1.7.0.4 不支持 --ignored 选项。我的git版本是1.7.6。另一个版本 1.7.5.1 是需要 -s 的版本。您可以尝试

git status -h

查看是否支持--ignored

This option --ignored does the trick:

git status --ignored

(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:

git status -s --ignored

(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 try

git status -h

to see if --ignored is supported.

鹤舞 2024-09-11 15:50:12

尝试使用 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.

绿萝 2024-09-11 15:50:12

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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文