Why Gerrit is unable to create branch by itself?

Viewed 21082

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?

4 Answers

Use this simple bash script to create and push a new branch to gerrit. Usage: Branch_name and CommitId are 2 inputs needed

#!/bin/bash 
read -p "Enter New Branch Name: " Branch_Name 

read -p "Enter CommitID:" CommitID 

git fetch --all 

git branch $Branch_Name $CommitID 

git push origin $Branch_Name:$Branch_Name 

git checkout $Branch_Name 

git branch --set-upstream-to=origin/$Branch_Name $Branch_Name
Related