git 子模块,忽略错误的目录

发布于 2024-08-30 20:58:19 字数 592 浏览 5 评论 0原文

我是 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 技术交流群。

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

发布评论

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

评论(2

夏至、离别 2024-09-06 20:58:19

关于使用子模块的方式,您需要了解的大部分内容总结在此处

您是否直接在视图中添加子模块?如果是,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.

如日中天 2024-09-06 20:58:19

我收回它......是我,显然有一次我必须以某种方式在该文件夹中提交实际的插件(也许意外地移动文件夹)我不记得这样做了......但无论如何我在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

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