Git修改远程仓库地址
2018-08-15 本文已影响1人
JouyPub
最近项目搬家,从Github搬到Gitee,所以大批项目需要修改仓库地址。至于为什么要从Github切换到Gitee,主要是因为Github有时确实太慢了,页面打不开,代码提交不上去。还有就是因为自己很多项目是私有的,总会出现两个网站来回切换。尽管Github是一个程序员的标配,但是在这种背景下,使用Gitee到也是不得已!
修改Git远程分支的方法有很多,这里只介绍几种
仓库A:https://github.com/xmvper/json
切换到
仓库B:https://gitee.com/jouypub/json
方法一:通过命令行修改远程地址
> cd json
> git remote set-url origin https://gitee.com/jouypub/json.git
方法二:先删除原有仓库地址,然后添加新地址
> cd json
> git remote rm origin
> git remote add origin https://gitee.com/jouypub/json.git
方法三:修改配置文件
> cd json/.git
> vim config
[core]
repositoryformatversion = 0
filemode = true
logallrefupdates = true
precomposeunicode = true
[remote "origin"]
# 修改成新的仓库地址
url = https://gitee.com/jouypub/json.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master