Unable to push my changes to gerrit


#1

I am trying to submit my first patch. When I try to push my changes I am facing this error:

syedsouban@git.haiku-os.org: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

PS: I have logged in on gerrit and also added my ssh keys from my github account.


#2

You’re attempting to push the code directly into our repository here.
Please use git review to make a code review request.


#3

In addition make sure you add your SSH keys to ssh-agent. I was having problems with that when trying to even pull from Gerrit.

https://help.github.com/en/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#adding-your-ssh-key-to-the-ssh-agent


#4

I am using this command to push:

git push origin master:refs/for/master

What is the syntax of git review?


#5

I followed that link and added ssh keys to github and gerrit both. I am still facing the same error!


#6

Facing the same error. I followed the instructions at CodingGuidelines/SubmittingPatches, and added my SSH key.

Should I use my github username, or the username in this forum?


#7

You need to use your Gerrit username. It is listed at https://review.haiku-os.org/settings/

Please show us the output of “git remote -v” so we can see how you have set up your repositories. It should look like this:

origin ssh://pulkomandy@git.haiku-os.org/haiku (fetch)
origin ssh://pulkomandy@git.haiku-os.org/haiku (push)

#8

OK, I am using the right username. The output of git remote -v is

origin  https://review.haiku-os.org/haiku (fetch)
origin  https://review.haiku-os.org/haiku (push)

Maybe https does not allow push?


#9

For http you would need to set up a password in Gerrit settings. I recommend switching to ssh, so you don’t need to type a password everytime you want to push something.


#10

It works, thanks.


#11

Output of git remote -v is:

origin ssh://syedsouban@git.haiku-os.org/haiku (fetch)
origin ssh://syedsouban@git.haiku-os.org/haiku (push)


#12

One more tip to getting SSH access working with Git and Gerrit (which had me stumped for a little while) - you need to create the SSH key pair and then use it.

There are lots of online docs about making ssh keys, you’ll end up with two files perhaps named, id_rsa_review for the secret key, and id_rsa_review.pub for the public one which you also upload to Gerrit.

Then tell your local ssh client to associate the key with the server, which means editing /boot/home/config/settings/ssh/config to add an entry like this (could be simplified):

Host haiku review.haiku-os.org
 HostName review.haiku-os.org
 IdentyFile ~/config/settings/ssh/id_rsa_review
 User agmsmith

My “git remote -v” lists origin ssh://agmsmith@review.haiku-os.org/haiku for both fetch and push. I also used that when doing the initial clone.