Reputation: 85
I have pulled a project from git repository(remote server). I did some modification.
Now I need to push as branch in a server not in main line.
For example, In server, V1->V2->V3.
My working area is on V2. And I want to push as V2.1. Not as V4.
Usual command i used for Pushing is git push origin HEAD:refs/for/master/issue5221
.
Is there some thing to replace master
in that command to push as a branch?
I tried some thing like this git push origin HEAD:refs/for/my_branch/issue5221
. But it is not working. Since "my_branch
" is not in remote server.
Upvotes: 2
Views: 979
Reputation: 30868
It seems you are using Gerrit. So you need ask the administrator to create the branch refs/heads/my_branch/issue5221
, after which you can push to refs/for/my_branch/issue5221
. If this is not an official branch, you can push it to a sandbox branch via git push origin HEAD:refs/sandbox/<your-username>/<any-name-you-want>
. refs/sandbox/<your-username>/*
cannot be fetched via git clone
, but can be done via git fetch origin refs/sandbox/<your-username>/* && git checkout FETCH_HEAD
. And other users are not allowed to update this ref.
Upvotes: 0
Reputation: 1324537
You should be able to push HEAD to a new branch (created on receiving the commit) with:
git push origin HEAD:my_branch/issue5221
(more generally, you can push a local branch to a remote repo on a different branch)
Upvotes: 1