将本地存储库推送到远程不会使用 GIT 推送子模块文件

发布于 10-27 10:37 字数 217 浏览 5 评论 0原文

我是 GIT 新手,正在努力解决这个问题。我有一个存储在存储库中的网站。该网站需要一个设置为单独存储库的主题文件夹。

我已成功使用 git submodule add 命令将主题存储库添加到我的网站。

所以现在我有一个带有主题儿童重现的网站重现。子模块的文件显示在我的网站文件夹中。

我正在尝试将整个主网站复制推送到可以工作的远程服务器,但主题(子模块)的文件不会被推送。

I'm new to GIT and am struggling with it. I've got a website that is stored in a repository. The website requires a theme folder that is setup as a separate repository.

I've used the git submodule add command successfully to add the theme repository to my website.

So now I have a website repro with a theme child repro. The files for the submodule are showing inside my website folder.

I'm trying to push the entire main website repro to a remote server which works but the files of the theme (submodule) are not pushed.

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

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

发布评论

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

评论(2

何必那么矫情2024-11-03 10:37:05

子模块非常像一个独立的存储库 - 它不知道它是否已作为子模块包含在父存储库中。父存储库也不太了解子模块 - 只是它应该在树中的位置,子模块应该位于哪个提交以及最初从哪个 URL 克隆它......

我不认为有一个命令可以将为您推送所有子模块 - 当您更新子模块中的某些文件时,事件的顺序应该是:

 cd theme

 # [Change or add some files, etc.]

 # Now commit those changes:
 git commit -a

 # Push them to the origin repository, assuming you're on the master branch:
 git push origin master

 # Change up to the parent repository:
 cd ..

 # Create a commit with the new version of that submodule:
 git add theme
 git commit -m "Committing a new version of the theme submodule"

 # Now push the commit that includes a pointer to the new submodule
 # version in the parent repository:
 git push origin master

这里的典型问题是在父存储库中推送一个提交,该提交引用了您尚未从子模块推送的子模块版本版本。您可能会发现创建脚本很有帮助,这样您就不会忘记任何这些步骤。

The submodule is very much like an independent respository - it knows nothing about whether it's been included as a submodule in the parent repository. The parent repository doesn't know that much about the submodule either - just where it should be in the tree, what commit the submodule should be at and what URL to initially clone it from...

I don't think there's a command that will push all your submodules for you - the sequence of events when you update some files in the submodule should be:

 cd theme

 # [Change or add some files, etc.]

 # Now commit those changes:
 git commit -a

 # Push them to the origin repository, assuming you're on the master branch:
 git push origin master

 # Change up to the parent repository:
 cd ..

 # Create a commit with the new version of that submodule:
 git add theme
 git commit -m "Committing a new version of the theme submodule"

 # Now push the commit that includes a pointer to the new submodule
 # version in the parent repository:
 git push origin master

The typical problem here is pushing a commit in the parent repository that references a submodule version that you haven't yet pushed from the submodule version. You may find it helpful to create a script so that you don't forget any of those steps.

飘落散花2024-11-03 10:37:05

我只是将主题目录添加为远程目录,而不是子模块。管理您自己的分支中的文件位置。主题的后续更新应移至正确的文件夹。

现在,推送将按照您最初的预期运行。

希望这有帮助。

I would just add the themes directory as a remote - not a submodule. Manage the files' location in your own branch. Subsequent updates of the theme should get moved to the proper folder.

A push will now behave as you originally intended.

Hope this helps.

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