Praveen Kumar Purushothaman
Praveen Kumar Purushothaman

Reputation: 167182

Unable to Cherry Pick (FETCH), but able to Pull & Push in Gerrit Git

As I said in the title, I am able to push to the gerrit, pull from the gerrit, but I am not able to cherry pick. When I asked the admin, he said I have all the rights to cherry pick, but I get the error as:

Error Message

Permission denied (publickey).
fatal: The remote end hung up unexpectedly

When I try to Pull and Rebase

praveen@praveen-vbox:~/work/myapp$ git pull --rebase
remote: Counting objects: 8888, done
remote: Finding sources: 100% (615/615)
remote: Total 615 (delta 416), reused 536 (delta 416)
Receiving objects: 100% (615/615), 267.47 KiB, done.
Resolving deltas: 100% (416/416), completed with 163 local objects.
From gerrit:myapp
   b7b8734..f5a782b  master     -> origin/master
First, rewinding head to replay your work on top of it...
Fast-forwarded master to f5a782b97079491e25638c9a752794e3af0a7543.

When I try to check the status

praveen@praveen-vbox:~/work/myapp$ git status
# On branch master
nothing to commit (working directory clean)

When I try to Commit

praveen@praveen-vbox:~/work/myapp$ git commit
[master 4c41a43] Minor fixes
 2 files changed, 2 insertions(+), 2 deletions(-)

When I try to Push

praveen@praveen-vbox:~/work/myapp$ git push gerrit:myapp HEAD:refs/for/master
Counting objects: 20, done.
Compressing objects: 100% (10/10), done.
Writing objects: 100% (10/10), 896 bytes, done.
Total 10 (delta 9), reused 0 (delta 0)
remote: Resolving deltas: 100% (9/9)
remote: Processing changes: updated: 1, done
To gerrit:myapp
 * [new branch]      HEAD -> refs/for/master

When I try to Cherry Pick

praveen@praveen-vbox:~/work/myapp$ git fetch ssh://[email protected]:29418/myapp refs/changes/24/5324/2 && git cherry-pick FETCH_HEAD
Permission denied (publickey).
fatal: The remote end hung up unexpectedly

Summary

My application runs on Ubuntu 12.04 on a VirtualBox instance. All my peers are able to cherry-pick, and I find the issue is only with my machine, and that too with cherry-pick by FETCH. What might be the issue? What do you guys suggest? What information other than this, do you need?


Update #1

Git Config

praveen@praveen-vbox:~/work/myapp$ git config --list
alias.s=status
alias.c=commit
alias.ca=commit --amend
alias.co=checkout
alias.dc=diff --color
alias.l=log --oneline
alias.pr=pull --rebase
alias.aa=add .
user.email=[removed] /* Removed before posting to SO. Email matches. */
core.editor=vim
color.ui=always
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
remote.origin.url=gerrit:myapp.git
branch.master.remote=origin
branch.master.merge=refs/heads/master

For Titas's query, the result is:

praveen@praveen-vbox:~/work/myapp$ git fetch gerrit refs/changes/96/5396/3
fatal: 'gerrit' does not appear to be a git repository
fatal: The remote end hung up unexpectedly

Also, when I do normally, this is the result:

praveen@praveen-vbox:~/work/myapp$ git fetch ssh://[email protected]:29418/myapp refs/changes/96/5396/3 && git cherry-pick FETCH_HEAD
Permission denied (publickey).
fatal: The remote end hung up unexpectedly

Update #2: SSH Config

As requested by RasmusØstergaardKjærVoss, I have included below the SSH Config file. Let me know if there's something to be changed.

praveen@praveen-vbox:~/work/myapp$ cat ~/.ssh/config
Host gerrit
HostName my.appdomain.com
Port 29418
User praveen
IdentityFile ~/.ssh/praveen_private

Upvotes: 3

Views: 5173

Answers (3)

Raji Gali
Raji Gali

Reputation: 13

This gave me the same error:

ssh [email protected]

changing to:

ssh [email protected]

fixed the problem for me.

Upvotes: 0

The ~/.ssh/, to my understanding git fetch ssh://[email protected]:29418/ will use the id_rsa key and not the ~/.ssh/praveen_private.

Backup your ~/.ssh folder Then try and create a copy of ~/.ssh/praveen_private named ~/.ssh/id_rsa If it is an rsa key otherwise copy it to ~/.ssh/id_dsa

Cheers

Upvotes: 1

Brad
Brad

Reputation: 5532

Something is wrong with your settings in git or gerrit, or in the overall settings for your gerrit deployment. You can run a git pull, which basically runs git fetch && git merge under the covers. But you can't run the git fetch command you copy-paste from gerrit. Look at the output of git remote -v and compare it to the git fetch portion of the cherry-pick command you are trying to run. Are you hitting the exact same server URL & port? As the same user?

Lastly, as a connection test to Gerrit, try running something like ssh username@gerrit_host -p 29418 gerrit ls-projects. This should return a list of projects on the Gerrit server, and is a good way to work out any setting issues.

Upvotes: 0

Related Questions