git 子模块,忽略错误的目录
我是 git 的新手,但在尝试之前花了很多时间阅读 git 子模块的文档和陷阱。我遇到了一个问题,我觉得——可能是天真地——是 git 中的一个错误:
我有一个项目,在该根目录中我有一个插件文件夹,其中有一个名为 myplugin 的子模块。我添加了它,
git submodule add xxxxxgithub.com/me/myplugin.git plugins/myplugin
效果很好。大约一周以来,一切都运行良好。我正在使用的框架支持覆盖插件内的视图。这些必须存储在
views/plugins/myplugin/customviewfile.
问题是,git认为覆盖文件夹也位于:
plugins/myplugin
Git不会在我的views/plugins/myplugin目录中提交任何内容,它不会跟踪文件,我不能忽略它不管我做什么。在 Github 中,它显示为绿色箭头,表明它是一个子模块,当我切换分支时,该目录会以子模块的方式继续运行,
我已经费了一个多小时了,没有任何进展……非常感谢任何帮助!
I am new to git but have spent a good deal of time reading through documentation and gotchas on git submodules before trying them. I am having a problem that I feel -- probably naively -- is a bug in git:
I have a project, in that root directory I have a plugins folder, which has a submodule called myplugin. I added it with
git submodule add xxxxxgithub.com/me/myplugin.git plugins/myplugin
which worked great. Everything has been working fine for about a week. The framework I'm using has support for overriding views that are inside a plugin. Those must be stored in
views/plugins/myplugin/customviewfile.
The problem is, git thinks that the override folder is also at:
plugins/myplugin
Git won't commit anything inside of my views/plugins/myplugin directory, it won't track the files, I can't unignore it no matter what I do. In Github it shows up with the green arrow indicating that it's a submodule and when I switch branches that directory carries over the way submodules do
I have been pulling my hair out for over an hour and making no progress... any help is greatly appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
关于使用子模块的方式,您需要了解的大部分内容总结在此处。
您是否直接在视图中添加子模块?如果是,
views/.gitmodules
包含什么?当您添加它时,您是否也在主项目中提交了(就在插件之上)?
但是,如果views是您的存储库的另一个克隆,您希望在其中看到
plugins/myplugin
子模块,那么您是否:git submodules init
git sumodules update
?
OP 添加:实际问题是
plugins
目录一度被忽略(rm 然后添加到.gitignore
文件中),使得任何子模块都无法检测到。Most of what you need to know about the way you work with submodules is summarize here.
Did you add the submodule directly in views? And if yes, what the
views/.gitmodules
contain?When you added it, did you also commit in your main project (just above plugins)?
But if views is another clone of your repo, where you expect to see
plugins/myplugin
submodules, did you:git submodules init
git sumodules update
?
The OP adds: the actual issue was
plugins
directory, at one point, was ignored (rm and then added to.gitignore
file), making any submodules undetectable.我收回它......是我,显然有一次我必须以某种方式在该文件夹中提交实际的插件(也许意外地移动文件夹)我不记得这样做了......但无论如何我在github历史中找到了它承诺。我 git rm -rf'ed 视图/插件目录,现在它可以工作了
I take it back... it was me, apparently one time I must have committed the actual plugins in that folder somehow (maybe moving folders around accidentally) I don't remember doing it.. but anyhow I found it in github history of commits. I git rm -rf'ed the views/plugins directory and now it's working