无法从 git 子模块推送提交?

发布于 2024-10-07 19:32:00 字数 902 浏览 3 评论 0原文

我有一个简单的项目,有一个子模块。

$ git submodule
 964737623a362f6303e87ec41f2c7090c8c2c093 lib/mongodb-php-odm (heads/master-1-g9647376)

我已经对该子模块进行了更改并提交了它们,但无法将它们推送到 github。

$ cd lib/mongodb-php-odm
$ git branch
* (no branch)
  master
$ git remote -v
origin  [email protected]:colinmollenhour/mongodb-php-odm.git
$ git ls-remote .
964737623a362f6303e87ec41f2c7090c8c2c093    HEAD
6f5f91eff9b1854faa30608f335aee92aa7532eb    refs/heads/master
6f5f91eff9b1854faa30608f335aee92aa7532eb    refs/remotes/origin/HEAD
6f5f91eff9b1854faa30608f335aee92aa7532eb    refs/remotes/origin/master
$ git push origin master
Everything up-to-date

我不明白为什么它说“一切都是最新的”,因为 964737 提交尚未推送到 github。我可能做错了什么,但我不知道那会是什么..

如何将此子模块中的最新提交推送到 github?

I have a simple project that has one submodule.

$ git submodule
 964737623a362f6303e87ec41f2c7090c8c2c093 lib/mongodb-php-odm (heads/master-1-g9647376)

I have made changes to that submodule and committed them, but cannot push them to github.

$ cd lib/mongodb-php-odm
$ git branch
* (no branch)
  master
$ git remote -v
origin  [email protected]:colinmollenhour/mongodb-php-odm.git
$ git ls-remote .
964737623a362f6303e87ec41f2c7090c8c2c093    HEAD
6f5f91eff9b1854faa30608f335aee92aa7532eb    refs/heads/master
6f5f91eff9b1854faa30608f335aee92aa7532eb    refs/remotes/origin/HEAD
6f5f91eff9b1854faa30608f335aee92aa7532eb    refs/remotes/origin/master
$ git push origin master
Everything up-to-date

I don't understand why it says "Everything up-to-date" because the 964737 commit has not been pushed to github. It is likely I did something wrong, but I have no idea what that would be..

How do I push the latest commit in this submodule to github?

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

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

发布评论

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

评论(2

辞取 2024-10-14 19:32:00

看来您没有提交任何分支,即您的提交不属于任何分支。在您所在的位置创建一个分支,然后启动 gitk 与 master 进行比较,然后根据需要进行挑选或重新设置。

It seems that you committed to no branch, i.e. your commit isn't part of any branch. Create a branch where you're standing, then launch gitk to compare to master, then cherry-pick or rebase as necessary.

看海 2024-10-14 19:32:00

@ColinM,我认为您应该将您的评论移至答案,因为它是完整的解决方案,它帮助我解决了完全相同的问题!谢谢——胡安·卡洛斯·莫雷诺

我会在这里做的。

正如谢弗所说,你正在进行“无头”提交。正如 ColinM 所说,您可以将该提交合并回 master,如下所示:

cd lib/mongodb-php-odm
git checkout master
git merge HEAD@{1}
git push origin master

编辑:使用 HEAD@{1} 而不是临时分支或标记更简单,因为没有需要清理。表达式 HEAD@{1} 表示 HEAD 的先前值,在本例中将是无头分支上的新提交。

@ColinM, I think you should move your comment to an answer because it is the complete solution, That helped me solve the exact same problem! Thanks – Juan Carlos Moreno

I'll do that here.

As Scheffer said, you're on a "HEAD-less" commit. As ColinM said, you can merge that commit back to master like this:

cd lib/mongodb-php-odm
git checkout master
git merge HEAD@{1}
git push origin master

EDIT: Using HEAD@{1} instead of a temporary branch or tag is simpler since there is no cleanup required. The expression HEAD@{1} means the HEAD's previous value which in this case would be the new commit on the headless branch.

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