如何执行“git status”?在未跟踪的目录上?

发布于 2024-09-04 20:38:27 字数 456 浏览 1 评论 0原文

我的一个子目录中有 6,000 个未跟踪的文件,我正在构建 .gitignore 文件来过滤掉不需要的文件。我正在通过运行“git status”来测试我的 gitignore 过滤器。

但是,我在不同子目录中有大量未跟踪的其他文件,因此“git status”也显示了所有这些文件,这使得很难看出 .gitignore 规则正在做什么。

如果文件被跟踪,那么我可以执行“git status”。它会将 git-status 输出限制为仅当前目录中的那些文件,但由于当前目录及其所有内容都未跟踪,因此“git status”。返回“错误:pathspec。与 git 已知的任何文件不匹配。”

我为此使用 git-1.6.6.1,尽管有趣的是我的测试表明 git-1.7.1(在不同的系统上)实际上允许您在未跟踪的目录上执行 git-status 。不幸的是我无法在这个系统上升级 git。 -1.6.6.1 是否有已知的解决方法?

I have 6,000 untracked files in one subdirectory and I'm constructing .gitignore files to filter out the unwanted ones. I'm testing my gitignore filters as I go by running 'git status'.

However, I have a larger number of untracked other files in a different subdirectory, so 'git status' shows all of those too, which makes it very hard to see what the .gitignore rules are doing.

If the files were tracked, then I could just do 'git status .' and it would restrict the git-status output to only those files in the current directory, but because the current directory and all its contents are untracked, 'git status .' returns "error: pathspec . did not match any file(s) known to git."

I'm using git-1.6.6.1 for this, although interestingly my testing shows that git-1.7.1 (on a different system) does actually let you do git-status on an untracked directory. Unfortunately I can't upgrade git on this system. Is there a known workaround for -1.6.6.1?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

旧情别恋 2024-09-11 20:38:27

您可以尝试:

git add --dry-run -A

You can try:

git add --dry-run -A
酒儿 2024-09-11 20:38:27

我会暂时将不需要的(不同的)子目录添加到 .gitignore 文件中,以便忽略其所有内容。然后,准备好后,从 .gitignore 中删除以前不需要的子目录的条目,以便它的文件再次被 git status 跟踪。

I would temporarily add the unwanted (different) sub-directory to the .gitignore file, so that all its contents are ignored. Then, when you're ready, remove the entry for the previously unwanted sub-directory from .gitignore so that its files become tracked by git status once more.

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