由于安全或者其它原因,我们可能会修改默认的SSH服务端口号,默认情况下,已有的git项目在pull或者push的时候会报错。
现在假设原来的项目的remote设置为git@linux.com:Projects/p1.git,将服务器SSH默认端口修改为3022后,导致push出错。
有两个解决办法:
一、直接修改URL为SSH://开头
git remote set-url origin ssh://git@linux.com:3022/~/Projects/p1.git
二、 修改本地配置文件
cat>~/.ssh/config
# 映射一个别名
host newlinux
hostname linux.com
port 3022
# ctrl+D
修改p1.git项目下的git配置文件
git remote set-url origin git@newlinux:Projects/p1.git
使用Git备份Linux上的网页文件:http://www.linuxdiyf.com/linux/2780.html
在项目开发中使用Git版本控制工具以提高效率:http://www.linuxdiyf.com/linux/1101.html
Ubuntu 15.04 Gogs(git版本库) 二进制安装:http://www.linuxdiyf.com/linux/11995.html
25个Git进阶技巧:http://www.linuxdiyf.com/linux/12077.html
Git使用入门教程:http://www.linuxdiyf.com/linux/9213.html