git:修改项目的remote地址(git version 2.30.2)

一,第一种方法:用remove命令删除origin

例子:我们把地址从apiweb1修改为apiweb2
查看remote
liuhongdi@lhdpc:/data/vue/apiweb$ git remote -v
origin  https://gitee.com/liuhongdi/apiweb1.git (fetch)
origin  https://gitee.com/liuhongdi/apiweb1.git (push)
删除remote的origin
liuhongdi@lhdpc:/data/vue/apiweb$ git remote remove origin
查看效果
liuhongdi@lhdpc:/data/vue/apiweb$ git remote -v
添加remote
liuhongdi@lhdpc:/data/vue/apiweb$ git remote add origin https://gitee.com/liuhongdi/apiweb2.git
查看效果
liuhongdi@lhdpc:/data/vue/apiweb$ git remote -v
origin  https://gitee.com/liuhongdi/apiweb2.git (fetch)
origin  https://gitee.com/liuhongdi/apiweb2.git (push)

说明:刘宏缔的架构森林是一个专注架构的博客,地址:https://www.cnblogs.com/architectforest

         对应的源码可以访问这里获取: https://github.com/liuhongdi/
         或: https://gitee.com/liuhongdi

说明:作者:刘宏缔 邮箱: 371125307@qq.com

 

二,第二种方法:用set-url命令

例子:把remote的地址从apiweb2修改为apiweb:
查看当前的remote
liuhongdi@lhdpc:/data/vue/apiweb$ git remote -v
origin  https://gitee.com/liuhongdi/apiweb2.git (fetch)
origin  https://gitee.com/liuhongdi/apiweb2.git (push)
用set-url进行设置
liuhongdi@lhdpc:/data/vue/apiweb$ git remote set-url origin https://gitee.com/liuhongdi/apiweb.git
查看效果
liuhongdi@lhdpc:/data/vue/apiweb$ git remote -v
origin  https://gitee.com/liuhongdi/apiweb.git (fetch)
origin  https://gitee.com/liuhongdi/apiweb.git (push)

三,查看git的版本:

liuhongdi@lhdpc:/data/vue/apiweb$ git --version
git version 2.30.2 
原文地址:https://www.cnblogs.com/architectforest/p/15330834.html