github 远程仓库名或地址修改,本地如何同步
1.背景
github远程仓库名变更,导致本地仓库失效。如何在原有仓库的基础上让本地仓库和新的远程仓库建立关联。
假设:
本地git项目目录为:testGit/
本地添加的远程仓库名为:origin
旧的远程仓库地址:https://github.com/yohayoha/testGit1.git
新的远程仓库地址:https://github.com/yohayoha/testGit.git
2.方法
方法一 直接修改
远程地址
- 进入testGit/ 根目录
- git remote 查看所有远程仓库:
git remote xxx
查看指定远程仓库地址(ps:此处的xxx为origin) - 修改旧仓库地址为:
git remote set-url origin https://github.com/yohayoha/testGit.git
- 查看地址是否已修改:
git remote -v
方法二 先删除
远程仓库再添加
远程仓库
- 进入testGit/ 根目录
- git remote 查看所有远程仓库, git remote xxx 查看指定远程仓库地址
git remote rm origin
git remote add origin https://github.com/yohayoha/testGit.git
方法三 修改配置文件
- 进入 testGit/ 根目录
- vim config
- 修改
[remote "origin"]
下面的url
地址
![图片](https://www.cnblogs.com/images/cnblogs_com/Ponchien/1502018/o_%e4%bc%81%e4%b8%9a%e5%be%ae%e4%bf%a1%e6%88%aa%e5%9b%be_20190712093740.png)