[SOLVED]Gerrit authentication failed

I cloned from review.haiku-os.org, created my Haiku Gerrit account, added my pubkey, configured my local git, made my code changes, made my commit. I get remote unauthorized when I go to push.

You should not push into master. Follow the guide here: https://dev.haiku-os.org/wiki/CodingGuidelines/SubmittingPatches#Submittingyourcommits

I was following that document. It seems ambiguous as to what branch to use.

git push origin <local source branch>:refs/for/<remote target branch>

Is the best info it gives regarding branches other than master.

1 Like

That info is correct. You don’t push to a branch directly, you push to refs/for/… which stores your commit on the server, but let others review it before its merged. It is not really a different branch, just a staging area for the master branch where code is reviewed.

In most cases, what you want is:

git push origin HEAD:refs/for/master

Basically, "push to origin my current commits (HEAD) for review against the master branch.

You can also install “git review” which will somewhat automate this.

Same result.

What does ‘git remote -v’ says?

What is the error, precisely?

~/src/haiku> git remote -v
origin  https://review.haiku-os.org/haiku (fetch)
origin  https://review.haiku-os.org/haiku (push)
~/src/haiku> git push origin HEAD:refs/for/master
Username for 'https://review.haiku-os.org': lazybullfrog
Password for 'https://lazybullfrog@review.haiku-os.org': 
remote: Unauthorized
fatal: Authentication failed for 'https://review.haiku-os.org/haiku/'

I figured it out. I had to generate and use an HTTP password in gerrit. That worked. I was using my github login that I used to log in to gerrit. Maybe this should be updated in the guide? Or perhaps the idea is that the easter egg hunt is part of the learning process. Ain’t learning fun? Thanks for the help! It got me thinking toward where my failure was.

You can either set an http password, or an ssh key, which I think the guide documents. When using an ssh key you don’t need to type your password, so this method is preferred.

Yes, from the wiki:

Create an account on ​Haiku’s Gerrit instance using your GitHub account, and add your SSH keys.

Note : Any commits submitted to Gerrit must have the same email address and user name as is in your Gerrit account, or else Gerrit will reject your submission!

I did this, but must have done it wrong. I’ll look to see what went wrong there.

You are pushing through HTTPS, not SSH. If you changed to push through SSH then it would work properly.

1 Like