拉取服务器代码(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 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区别_惠菁的博客-优快云博客