2

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.

user2732944
  • 75
  • 2
  • 4
  • 10

2 Answers2

1

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)

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

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.

ElpieKay
  • 27,194
  • 6
  • 32
  • 53