Normally when I do a push in git I do something like
git push origin master, which really means push from the local branch named
master to the remote branch named
master. If you want to push to a remote branch with a different name than your local branch, separate the local and remote names with a colon:
git push origin local-name:remote-name
17 thoughts on “git: Pushing to a Remote Branch with a Different Name”
thank you very much！！！！
That is awesome! Exactly what I was looking for.
Thanks a lot! I couldn’t remember how to push to a remote with a different name to save my life
Awesome thank you so much!!!!
Thanks! Also in case anyone finds this useful, HEAD can be used to reference the current branch. For example push current branch to origin master: git push origin HEAD:master
Nice, neat explanation
Exactly what i was looking for thanks
This is great! Thanks.
i have two branches: BranchA and BranchB
on the remote branchB is ahead of branch A
but on my local i merged branchB with Branch A
and now i made few changes in branch A
i want to push all these changes to the branchB,
how to do that
It sounds like your branchA now has a different history than your branch B, which would make it so you can’t push. You may need to merge your remote branchB into your local branchA and try again. Alternatively, if you’re okay with overwriting your remote branchB and the work you’ve done there you can force push your local branchA to your remote branchB.
short and to the point