.gitignore 和 Untracked 文件出现问题
您好,
我在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不可能在 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.