Steve Chambers Steve Chambers - 1 year ago 84
Git Question

How to create a remote Git branch without creating a local branch?

I'd like to create a new remote branch for later use.
The most commonly suggested way seems to be:

git checkout -b newbranch origin/startingpoint
git push origin newbranch

But this will also create the branch locally and put me on it. Is there a way of creating a remote branch without creating it locally and moving onto it?

Answer Source

push demands a local ref, though it seems to me now that's a bit arbitrary. But it doesn't care what the local ref is called, you can say what remote name you're pushing to directly, so:

git branch junkname origin/startingpoint
git push origin junkname:newbranch
git branch -d junkname
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download