bash 无法安装 Gerrit 的 commit-msg 钩子;身份验证似乎没问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23108848/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Unable to install Gerrit's commit-msg hook; authentication seems fine
提问by trejder
I've just upgraded my Git tools to newest versions (TortoiseGit 1.8.8.0, PuTTy 0.63and 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.
我刚刚将我的 Git 工具升级到最新版本(TortoiseGit 1.8.8.0、PuTTy 0.63和Git Bash for Windows 1.9.0)并应用了 Git Bash 在git pull
. 我按照公司内部关于克隆新本地存储库的说明进行操作,但未能安装 Gerrit 的commit-msg
钩子。
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.
scp -p -P 29418 [USERNAME]@[HOST]:hooks/commit-msg .git/hooks/
在 Git Bash 中执行后,我收到错误Permission denied (publickey)
。但是,我的 SSH 密钥和其他组件似乎一切正常,因为我可以git pull
/git push
没有任何问题 Git Bash 不反对任何有关丢失或不正确身份验证的内容,并继续进行所有其他需要身份验证的操作。
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?
是什么导致了这个奇怪的错误(这与我的本地计算机或 Gerrit 安装有关)?如何解决这个问题呢?而且——最重要的(或最奇怪的)——怎么可能,安装commit-msg
钩子时认证失败,而在推/拉/其他需要认证的命令上工作正常?
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?
我设法找到了一个丑陋的解决方法,通过commit-msg
从另一个存储库复制(它已经存在了一段时间,在所有这些问题开始出现之前,因为我也无法commit-msg
在这个存储库中安装/覆盖钩子——出于同样的原因) . 但我想知道,这里发生了什么,或者我在这个案例中遗漏了什么?
回答by uncletall
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
Git 有一个选项可以指定使用哪个 ssh,它使用 Plink 而不是 Bash ssh。当您使用 scp 时,它使用 Bash ssh。您也可以通过以下方式commit-msg
直接从 gerrit 服务器下载钩子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.
如果您总是使用 Gerrit,那么我建议您将 commit-msg 钩子复制到C:\Program Files (x86)\Git\share\git-core\templates\hooks
. 这样,当您克隆存储库时,commit-msg
挂钩将始终放置在您的.git\hooks
文件夹中。因为我 90% 的时间都在 Gerrit 存储库上工作,所以我发现在不需要时删除它然后在需要时添加它更容易。
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.
否则,您可以生成一个新的 ssh 密钥并添加它。然后你有一个用于命令行目的的密钥,使用 ssh 和 scp,另一个用于使用 PLink 的 Git。
Actually, for my company I now ensure that new installs always specify to use SSH and not PLink as it prevents problems like this.
实际上,对于我的公司,我现在确保新安装始终指定使用 SSH 而不是 PLink,因为它可以防止此类问题。