Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to push commits from a git submodule?

Tags:

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?

like image 805
ColinM Avatar asked Dec 15 '10 00:12

ColinM


People also ask

Can I push changes from submodule?

You can treat a submodule exactly like an ordinary repository. To propagate your changes upstream just commit and push as you would normally within that directory.

How do you push a submodule?

In the parent repo, you can also use git push --recurse-submodules=check which prevents pushing the parent repo if the submodule(s) are not pushed first. Another option is git push --recurse-submodules=on-demand which will try to push the submodules automatically (if necessary) before pushing the parent repo.

How do you commit changes in a submodule?

Use the git submodule update command to set the submodules to the commit specified by the main repository. This means that if you pull in new changes into the submodules, you need to create a new commit in your main repository in order to track the updates of the nested submodules.

How do you fix a dirty submodule?

You can fix it by: either committing or undoing the changes/evolutions within each of your submodules, before going back to the parent repo (where the diff shouldn't report "dirty" files anymore). To undo all changes to your submodule just cd into the root directory of your submodule and do git checkout .


1 Answers

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.

like image 68
Mauricio Scheffer Avatar answered Oct 27 '22 19:10

Mauricio Scheffer