Search code examples
gitgit-branchgerritgit-pushgit-bash

Failed to push some refs to remote repository (prohibited by Gerrit)


I know this might have been asked before but I would like to understand the issue. I am trying to push a newly-created branch from my local repository to the remote repository. Here are the actions that I've taken:

  1. Create a clone repository in my local system.
  2. Create a new branch locally (named here as 'Newbranch'). Note that the branch is not existing in the remote repository.
  3. Push Newbranch to the remote repository.

I received this error message after making the push:

Total 0 (delta 0), reused 0 (delta 0)
remote: Processing changes: refs: 1, done
To 'remote repository URL'
! [remote rejected] Newbranch -> Newbranch (prohibited by Gerrit)
error: failed to push some refs to 'remote repository URL'

Can someone walk me through the error code? What steps are needed to be taken to resolve and to be able to create a new branch in the remote? I'm just starting to use Git. If this will help, the git repository is powered by Gerrit Code Review. Your response will be highly appreciated.


Solution

  • For creating and pushing a new branch to the remote repository, you should :

    git checkout -b [new_branch_name]
    
    git push -u origin [new_branch_name]
    

    For resolving the error you are facing :

    [remote rejected] Newbranch -> Newbranch (prohibited by Gerrit) error: failed to push some refs to 'remote repository URL'

    you should check your user credentials with the system administrator, since he should first grant the permission to create a new branch, to your user account.

    The permission configurarion for Gerrit is completely explained in the documentations.