Git push到远程gitlab报错问题

问题描述:

无法实现push操作到gitlab的远程仓库

问题产生流程:

远程仓库地址变更

执行了命令:

git remote rename origin old-origin

git remote add origin git@53b2231cd9de:root/translate.git

异常提示(执行 git push -u origin master):

ssh: connect to host 127.0.0.1 port 22: Connection refusedfatal: Could not read from remote repository.Please make sure you have the correct access rightsand the repository exists.

问题解决:

git remote set-url origin http://127.0.0.1:32767/root/translate.git

设置远程url地址使用http协议,不再使用SSH协议

备注:

这个问题产生的原因应该是docker虚拟出来的端口映射,把22映射成32776导致的,

再使用SSH做clone或push的时候直接走22端口,实际上SSH应该走32776端口。

在解决问题的过程中,以为是端口的问题,却没有注意所采用的协议是什么,写法类似

git@xxxx.com:root/translate.git是SSH协议的写法,后采用http协议后问题

轻松解决(http://127.0.0.1:32767/root/translate.git)。

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容