.gitignore 和 Untracked 文件出现问题

发布于 2024-09-28 12:42:52 字数 761 浏览 0 评论 0原文

您好,

我在使用 Git 和使用 .gitignore 时遇到了一个奇怪的问题。我的结构中有一个文件夹(包含内容),当前未被 git 跟踪,因为当我执行 git status 时,它显示在未跟踪文件下。我将其路径添加到 .gitignore 但再次尝试 git status,它仍然存在!其他文件/文件夹,我做了同样的事情,它们消失了,但这个文件夹没有。我做错了什么?

更新

文件夹结构是:

folder_foo/folder_bar/folder_baz/file_foo
folder_foo/folder_bar/folder_baz/file_bar
folder_foo/folder_bar/.htaccess

我的.gitignore是:

folder_foo/folder_bar
!folder_foo/folder_bar/.htaccess

当我运行git status时,表示该文件夹< code>folder_foo/folder_bar/ 未跟踪。 我现在发现,如果我从 .gitignore 中删除第二行,那么它就可以正常工作。所以我想出了这个解决方案:

folder_foo/folder_bar
!.htaccess

为什么我必须这样做而不指定确切的 .htaccess 文件?

Greetings,

I have a weird problem with Git and using .gitignore. I have a folder (that has contents) in my structure that is currently not getting tracked by git because it shows up under the Untracked files when I do git status. I add it's path to .gitignore but try git status again and it is still there! Other files/folders, I do the same thing and they disappear, but not this folder. What am I doing wrong?

Update

The folder structure is:

folder_foo/folder_bar/folder_baz/file_foo
folder_foo/folder_bar/folder_baz/file_bar
folder_foo/folder_bar/.htaccess

My .gitignore is:

folder_foo/folder_bar
!folder_foo/folder_bar/.htaccess

When I run git status is says that the folder folder_foo/folder_bar/ is untracked.
I've figured out now that if I remove the second line from the .gitignore then it works fine. So I've come up with this as a fix:

folder_foo/folder_bar
!.htaccess

Why is it that I have to do it that way and not specify the exact .htaccess file?

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

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

发布评论

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

评论(1

远山浅 2024-10-05 12:42:52

我不可能在 git 1.7.0.4(在 Mac 10.6 上)上重现此内容。

我能想到的唯一解释是您正在查看其他(旧)版本中的错误。

It is not possible for me to reproduce this on git 1.7.0.4 (on Mac 10.6).

The only explanation I can think of that you are looking at a bug in an other (older) version.

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