I have an untracked branch that was originally cloned from a remote branch called origin/develop
. I want to push this branch to the remote branch origin/feature/A
. origin/feature/A
does not exist yet. I want it to be created when I push. We already have branches origin/feature/XYZ
on the remote and I'm trying to stay consistent. The branch locally is called A
.
How do I do this?
You should be able to git push origin A:feature/A
.
From the documentation:
<refspec>…
Specify what destination ref to update with what source object. The format of a
<refspec>
parameter is an optional plus +, followed by the source object<src>
, followed by a colon:
, followed by the destination ref<dst>
.…
The
<dst>
tells which ref on the remote side is updated with this push.
As knittl points out in the comments, you can add the -u
flag to make your local A
branch track the new origin/feature/A
branch.