项目中会因为很多情况需要更改远程仓库地址,比如项目迁移或者远程仓库换了新的ip等。未重置之前与远程的操作会出现如下的错误提示
fatal: unable to access 'http://39.118.252.142/fe/test.git/': Failed to connect to /39.118.252.142 port 80: Timed
out
旧地址:http://39.118.252.142/fe/test.git
新地址:http://git.ouyang.cn/fe/test.git
1、通过命令直接重置
> git remote set-url origin http://git.ouyang.cn/fe/test.git
2、修改配置文件
> cd test/.git
> vim config
[core]
repositoryformatversion = 0
filemode = true
logallrefupdates = true
precomposeunicode = true
[remote "origin"]
# 在这儿修改成新的仓库地址
url = http://git.ouyang.cn/fe/test.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
3、先删除后添加
> git remote rm origin
> git remote add origin http://git.ouyang.cn/fe/test.git