开发者

Unable to push commits from a git submodule?

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  git@github.com: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开发者_C百科 wrong, but I have no idea what that would be..

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


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.


@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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜