Geriit使用出错记录

文章描述了在使用Git进行代码拉取和提交时遇到的SSH连接问题,包括key交换算法不匹配和缺少Change-Id的问题。解决方案涉及修改.ssh/config文件,添加兼容算法,以及设置Git的默认编辑器Notepad++来正确处理commit-msg钩子。此外,还提到了可能因协议版本不兼容导致的commit-msg文件丢失的问题,需要手动拉取该文件并重试。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

拉取服务器代码(clone )

1、执行:git clone ssh:xxxxxx && scp -p -P 29418 xxxxxxxxx

1、报错:Unable to negotiate with XX.XX.XX.XX port XX:: no matching key exchange method found. Their offer: diffie-hellman-group1-sha1
fatal: Could not read from remote repository.

问题解决:进入本机 .ssh目录,在下面新建一个config文件,不带后缀名,配置如下

Host *
KexAlgorithms +diffie-hellman-group1-sha1

2、再次执行:git clone。。。

2、报错: Unable to negotiate with xxxxxxx port 29418: no matching host key type found. Their offer: ssh-rsa,ssh-dss

问题解决:config文件增加下面两条

Host *
   KexAlgorithms +diffie-hellman-group1-sha1
   HostkeyAlgorithms +ssh-rsa
   PubkeyAcceptedAlgorithms +ssh-rsa

参考:
解决:no matching key exchange method found. Their offer: diffie-hellman-group1-sha1_zombres的博客-优快云博客
 Git Bash - ssh连接问题答案 - 爱码网

提交代码(push)

1、执行: git push origin HEAD:refs/for/master

1、报错:missing Change-Id in commit message footer

解决方法1 

问题解决:执行第二个红框的代码

2、执行上面代码 

2、再次执行报错

subsystem request failed on channel 0.
scp:Connection closed

问题解决:将scp -p -P改为scp -O(大写) -P即可

 第二个红框的代码执行成功。

3、执行:git commit --amend

3、再次执行报错:

hint: Waiting for your editor to close the file... C:\Program Files (x86)\Notepad++\notepad++.exe: -c: line 1: syntax error near unexpected token `('
C:\Program Files (x86)\Notepad++\notepad++.exe: -c: line 1: `C:\Program Files (x86)\Notepad++\notepad++.exe "$@"'
error: There was a problem with the editor 'C:\Program Files (x86)\Notepad++\notepad++.exe'.

问题解决:执行 

git config --global core.editor "'C:/Program Files (x86)/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin '$*'"

会通过notepad打开文件,不需要做任何改动,直接退出即可。

参考:

记录一次git 提交代码出现的问题_gitdir=$(git rev-parse --git-dir) : 无法将“gitdir=$(g_何小白besthyq的博客-优快云博客

Git Bash 设置Notepad++作为默认编辑器_actionPig的博客-优快云博客

执行git log,生成Change-Id。再次push,成功。

解决方法2

原因是本地的scp或者ssh的版本比gerrit服务器上的高,导致了服务器识别不了请求中的协议导致的。git clone 命令 拉取代码的时候没有下载到git的隐藏文件:D:\code\.git\hooks下的 丢失了这个文件 commit-msg 

1、首先撤销修改:Revert Commit。

2、重新拉取代码:在scp参数中手动添加“-O”参数,以让客户端使用兼容协议。修改后的命令如下:git clone ssh://xxx@127.0.0.1:29418/code && scp -O -p -P 29418 xxx@127.0.0.1:hooks/commit-msg "code/.git/hooks/"

参考

Git 通过change push代码时,失败 提示没有找到change-id_pushing without change-id is deprecated-优快云博客

【git】Idea使用 Undo Commit,Revert Commit,Drop Commit区别_惠菁的博客-优快云博客

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值