Git查看当前仓库地址并切换新的仓库地址

项目场景:

项目更换了仓库地址,Python工程和Java工程(均适用)不重新 git clone 进行克隆仓库,直接切换新的地址。以下实现Git查看当前仓库地址以及Git切换新的仓库地址


Git查看当前仓库地址:

方式一:git remote -v 示例:

D:\PythonProject>git remote -v
origin  https://github.com/Xxxxxxxx/Xxxxxx.git (fetch)
origin  https://github.com/Xxxxxxxx/Xxxxxx.git (push)

方式二:git remote show origin 示例:

D:\PythonProject>git remote show origin
* remote origin
  Fetch URL: https://github.com/Xxxxxxxx/Xxxxxx.git
  Push  URL: https://github.com/Xxxxxxxx/Xxxxxx.git
  HEAD branch: master
  Remote branches:
    master                           tracked
  Local branches configured for 'git pull':
    master merges with remote master
  Local refs configured for 'git push':
    master pushes to master (up to date)


Git切换新的仓库地址:

.git 文件所在目录下执行:
git remote set-url origin 新仓库地址 示例:

D:\PythonProject>git remote set-url origin https://github.com/Yyyyyyyyy/Yy.git

以上便将工程的原仓库地址 https://github.com/Xxxxxxxx/Xxxxxx.git 切换为新仓库地址 https://github.com/Yyyyyyyyy/Yy.git

可以 git pull origin 分支名 拉取代码啦。

  • 6
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值