James Wierzba James Wierzba - 6 months ago 48
Git Question

How to create new branch in a remote?

I have made a mistake with my git branch workflow

I have the following local and remote branches setup:

master -> origin/master
iteration5 -> origin/iteration5
iteration9 -> origin/iteration5

I need the upstream on my local branch (
) to be set to a remote branch called

Given the current state of my repo, how can I create a remote branch called
based off of my local branch
, if it is already pointing to an old remote branch (


You can remove it with

git branch --unset-upstream iteration9

then reset it by pushing to origin with the --set-upstream flag:

git push --set-upstream origin iteration9

or you can set it with this command if the remote branch already exists:

git branch --set-upstream-to=origin/iteration9