Why Gerrit is unable to create branch by itself?

trejder picture trejder · Dec 16, 2013 · Viewed 19.1k times · Source

Following this answer and my own question, I have a simple (hope so) question.

If I'm pushing a particular branch, with all required refs properly set:

git checkout 82-blah-blah
git push origin HEAD:refs/for/82-blah-blah

Why do I always get:

! [remote rejected] HEAD -> refs/for/82-blah-blah (branch 82-blah-blah not found)

and I always have to go to Gerrit's UI and create that branch manually?

Isn't that an obvious step, that Gerrit could simply automate? Or am I missing something?

Answer

uncletall picture uncletall · Dec 17, 2013

The accepted answer is referring to a feature that allows users to create branching using SSH, all it adds is the CreateBranchCommand. The original issue request might actually refer to what @trejder wants but the implementation is just a create branch through an SSH command.

I was under the impression that if you have the create-reference right you can push to ref/for/new-branch but I was wrong, just tested it and it doesn't work. It only allows you to create new branches but directly pushing to them.

Guess the fastest way to get it done is:

git checkout master
git push origin HEAD:new-branch
git checkout new-branch
git push origin HEAD:/refs/for/new-branch