Question

I've just upgraded my Git tools to newest versions (TortoiseGit 1.8.8.0, PuTTy 0.63 and Git Bash for Windows 1.9.0) and applied fix for Git Bash hanging forever after git pull. I followed my inner company instructions on cloning new local repository and I failed on installing Gerrit's commit-msg hook.

After executing scp -p -P 29418 [USERNAME]@[HOST]:hooks/commit-msg .git/hooks/ in Git Bash, I'm getting error Permission denied (publickey). However, everything seems to be fine with my SSH keys and other components, as I can git pull / git push without any problems Git Bash does not objects anything about missing or incorrect authentication and proceeds with all other operations, that requires authentication.

What can be causing this strange error (is this something with my local computer or Gerrit installation)? How to solve this problem? And -- the most important (or most curious) -- how it is possible, that authentication fails on installing commit-msg hook, while works fine on pushing / pulling / other commands requiring authentication?

I managed to find an ugly workaround, by copying commit-msg from another repository (it was there for some time, before all these problems started to appear, as I can't install / overwrite commit-msg hook in this repo as well -- for the same reasons). But I'd like to know, what is happening here or what am I missing about this case?

Was it helpful?

Solution

Git has an option that specifies which ssh to use, it uses Plink and not the Bash ssh. When you use scp it uses the the Bash ssh. You can also download the commit-msg hook directly from the gerrit server via https://yourserver/r/tools/hooks/commit-msg

If you are always working with Gerrit than I would recommend that you would copy the commit-msg hook to C:\Program Files (x86)\Git\share\git-core\templates\hooks. This way the commit-msg hook will always be placed in you .git\hooks folder when you clone a repository. As I work 90% of my time on Gerrit repositories I find it easier to delete it when I don't need it then to add it when I need it.

Or else, you can generate a new ssh key and add this as well. Then you have one key for command line purposes uses ssh and scp and one for Git using PLink.

Actually, for my company I now ensure that new installs always specify to use SSH and not PLink as it prevents problems like this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top