如何将一个Git仓库迁移到另外的Git仓库

一、第一步

把服务器上得所有分支和tag先拉取到本地

  • 拉去分支到本地

    git branch -a 查看所有的分支

    git checkout branch-name 检出指定分支到本地

  • 拉去所有的TAG 到本地

    git fetch --tags

二、 更换远端资源连接到新的连接
  • git remote rm origin 清除本地和远端的资源连接
  • git remote add origin <url to NEW repo> 建立新的连接
三、把本地的资源推到新仓库
  • git push origin --all
  • git push --tags
posted @ 2021-01-26 09:24  zero_7  阅读(849)  评论(0编辑  收藏  举报