Git修改远程仓库地址

  最近项目搬家,从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

欢迎订阅「K叔区块链」 – 专注于区块链技术学习

《Git修改远程仓库地址》

博客地址:
http://www.jouypub.com

简书主页:
https://www.jianshu.com/u/756c9c8ae984

segmentfault主页:
https://segmentfault.com/blog/jouypub

腾讯云主页:
https://cloud.tencent.com/developer/column/72548

    原文作者:JouyPub
    原文地址: https://segmentfault.com/a/1190000016026052
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞