当前位置:   article > 正文

从gerrit拉代码(windos外网http模式和Linux内网ssh模式)_gerrit怎么拉代码

gerrit怎么拉代码

提示:刚到公司几天的实习生遇到问题,记录一下


一、Linux从gerrit拉用ssh方式代码–仅需要加ssh

提示:git配置步骤已在公司管理员那里配置完成,这里仅仅关心如何从gerrit拉代码
参考:https://www.csdn.net/tags/MtjaEg3sNTM1MzYtYmxvZwO0O0OO0O0O.html
1.获取账号密码,一般是公司管理员给你邮箱。
2. 生成ssh密钥对
(1) 确认是否已经有密钥对
ls ~/ssh ·
(2) 密钥对重新生成步骤
在linux系统终端执行:
ssh-keygen -t rsa -C “xxx@xxx.com”
(3) Gerrit网页配置
获取公钥 cat ~/.ssh/id_rsa.pub,复制全部内容
登录Gerrit, Settings -> SSH Public Key -> 粘贴刚刚复制的内容->Add Key
(4)验证:
在终端执行 git clone ssh://namexx@xxxxxx/某分支… 拉一个代码试试,成功。

3.no matching host key type found. Their offer: ssh-rsa
https://blog.csdn.net/qq_27577263/article/details/121079772?spm=1001.2101.3001.6650.2&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-2-121079772-blog-124042887.pc_relevant_multi_platform_whitelistv1&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-2-121079772-blog-124042887.pc_relevant_multi_platform_whitelistv1&utm_relevant_index=5

踩坑: ! [remote rejected] head -> refs/for/master (change 19215 closed) error: failed to push some …
https://www.cnblogs.com/yongdaimi/p/12583189.html

踩坑1:Linux SSH 远程登录错误解决办法 WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!

解决:
https://blog.csdn.net/nahancy/article/details/51052127?spm=1001.2101.3001.6661.1&utm_medium=distribute.pc_relevant_t0.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1-51052127-blog-82153160.pc_relevant_default&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1-51052127-blog-82153160.pc_relevant_default&utm_relevant_index=1

ssh-keygen -R 172.16.152.209

ssh: connect to host 192.168.1.101 port 22: No route to host
lost connection

踩坑2:ssh安装

https://blog.csdn.net/qq_40748967/article/details/122492545
如果ssh登录不上这台机器,一般就是没有安装ssh服务

踩坑3:ssh登录远程服务器时提示Permission denied (publickey,password)

https://blog.csdn.net/weixin_41891385/article/details/118631106

二、在windows下从gerrit上面拉代码

用https下载代码

在家一般笔记本是windows系统,想拉代码看一下,尝试从外网方式下载gerrit仓库代
1.搜索 git for windows,从官网下载安装
2.windos开始菜单找到 “Git CMD”,执行:
git clone https://namexx@xxxxxx/某分支…
3.Git报错解决:fatal: unable to access ‘https://github.com/…’: OpenSSL SSL_read: Connection was reset, errno 10054
产生原因:一般是这是因为服务器的SSL证书没有经过第三方机构的签署,所以才报错
解决办法:git config --global http.sslVerify “false”
参考:https://www.jianshu.com/p/a155d093177e
4.重新拉代码,成功。

ssh方式:(难点:linux命令和cmd命令不通用)

1.安装git配置ssh:
参考:https://blog.csdn.net/GaoFeng535/article/details/104831054?spm=1001.2101.3001.6661.1&utm_medium=distribute.pc_relevant_t0.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1-104831054-blog-90743756.experiment_layer_sa&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1-104831054-blog-90743756.experiment_layer_sa&utm_relevant_index=1
2.报错总结:
(1)没有安装git报错:‘git’’ is not recognized as an internal or external command, operable program or batch file.
(2)配置ssh key:ssh-keygen -t rsa -C "xxx@xxx.com"后,git clone时
报错:Unable to negotiate with xx.xxx.x.x port 29418: no matching host key type found. Their offer: ssh-rsa fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
解决:配置一下ssh:在D://User/xxx/.ssh中新建(存在直接添加下面即可)config文件,用记事本打开添加:
Host *
HostkeyAlgorithms +ssh-rsa
PubkeyAcceptedKeyTypes +ssh-rsa
KexAlgorithms +diffie-hellman-group1-sha1
(ps:我也不知道哪句起作用了)
最后保存退出后,出现打开一个git Bash窗口执行git clone代码,成功。

三、git 杂项补充

git fetch :在这里插入图片描述

先git reset --hard 在git fetch,可以恢复到某次代码提交的changeID,继续修改进行提交。

强制拉最新代码覆盖本地的代码:

https://blog.csdn.net/dpengwang/article/details/82821203?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522166115305616782425161767%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=166115305616782425161767&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2allfirst_rank_ecpm_v1~pc_rank_34-1-82821203-null-null.142v42pc_rank_34_ctr25,185v2control&utm_term=%E5%BC%BA%E5%88%B6pull%E6%9C%80%E6%96%B0%E7%9A%84%E4%BB%A3%E7%A0%81&spm=1018.2226.3001.4187

git fetch --all
git reset –hard origin/master
git pull

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/527555
推荐阅读
相关标签
  

闽ICP备14008679号