git: Pushing to a Remote Branch with a Different Name

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
git: Pushing to a Remote Branch with a Different Name

14 thoughts on “git: Pushing to a Remote Branch with a Different Name

  1. subi says:

    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

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s