远程仓库服务器迁移后,git本地仓库修改远程分支映射

本地没有需要提交代码,可以删库,重新clone,不删库方案如下

不删库方案

  • 移除原有origin, git remote rm origin
  • 添加新的origin url, git remote add origin [URL]
  • 映射本地分支与远程分支 git branch --set-upstream-to=origin/[远程分支] [本地分支], 自行替换自己分支

以上即可完成本地与远程映射,

特殊状况

  • 如果分支映射失败,请检查远程分支是否丢失,丢失请自行建立分支
  • 注意查看git的提示信息, 如果远程分支存在,那应该只是远程分支在本地没有同步,执行git remote update origin 重新更新远程分支列表
  • 再次执行分支映射即可

hint:
hint: If you are planning on basing your work on an upstream
hint: branch that already exists at the remote, you may need to
hint: run “git fetch” to retrieve it.
hint:
hint: If you are planning to push out a new local branch that
hint: will track its remote counterpart, you may want to use
hint: “git push -u” to set the upstream config as you push.

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值