git仓库迁移

我们有时候需要迁移git仓库,但又想保留每次commit的记录,所以我们只需要更改git remote [源]的问题即可

  • 首先查看你的remote的地址

    git remote -vv
    

git 仓库迁移,git remote 更改源

origin 是自己远程仓库的分支,upstream是远程主仓库的分支

  • 我们采用先删除后增加

    git remote rm upstream  // 删除远程仓库源地址
    
    git remote add upstream [需要更换远程仓库的git地址] // 添加分支
    
  • 然后我们就把本地代码进行提交

    git push upstream dev // 把本地仓库地址 提交到新的远程仓库
      // 如果我们是迁移仓库,想用原有仓库覆盖远程仓库的代码,直接
    git push -u upstream dev -f 即可
    

现在我们就可以看到新的远程仓库保留之前的commit记录了

相关文章:

  • 2021-07-07
  • 2021-08-15
  • 2021-09-26
  • 2021-12-08
  • 2021-07-17
  • 2022-12-23
  • 2021-12-06
猜你喜欢
  • 2021-07-20
  • 2018-10-24
  • 2022-02-09
  • 2021-10-15
相关资源
相似解决方案