Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Meigyoku-Thmn/1e52cb07d330dc68bd850b43f0d1ef16 to your computer and use it in GitHub Desktop.
Save Meigyoku-Thmn/1e52cb07d330dc68bd850b43f0d1ef16 to your computer and use it in GitHub Desktop.
How to pull, commit and push to remote branch in submodule

Submodule in git is always in detached state, there is no other way.

If you want to update submodule:

git checkout master #or <your remote branch name>

If you want to pull and merge submodule:

git pull origin master #or <your remote branch name>

First, you commit like usual, but then you have to clarify the destination in your push command.

If you want to push to the remote master branch (the default one):

git push origin HEAD:master

If you want to push to a certain remote branch:

git push origin HEAD:<your remote branch name>

SourceTree should ask you where to push your commit to. But not like that in Visual Studio Code, you still have to do it by hand typing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment