前提条件:SSH配置正确,代码正常拉取,没有change-id,按照提示执行,报如下错
gitdir=$(git rev-parse --git-dir); scp -p -P xxx xxx@xxx:hooks/commit-msg ${gitdir}/hooks/
subsystem request failed on channel 0
scp: Connection closed
解决办法:将提示方法中的scp -p改为scp -O,问题解决
gitdir=$(git rev-parse --git-dir); scp -O -P xxx xxx@xxx:hooks/commit-msg ${gitdir}/hooks/
问题原因:如评论区大佬:try to use -O option with scp. This solved the same issue in my case with 9.0p1. It forces to use the legacy SCP protocol for file transfers instead of the SFTP protocol. Use of the SCP protocol may be necessary for servers that do not implement SFTP, for backwards-compatibility for particular filename wildcard patterns and for expanding paths with a ‘~’ prefix for older SFTP servers. Found here
解决历程:
按照提示处理,报错无法解决。
1、通过while scp确实scp存在
2、尝试从网上寻找生成commit-msg文件其他方法,一个纯代码无效,一个建议将sample文件去掉后缀无效
3、bing搜索解决办法,在一个论坛上找到类似问题,解决办法-p改为-O
ps:期间甚至怀疑SSH异常,重配SSH
怀疑代码异常,重新拉取代码