git 仓库迁移

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u010221508/article/details/87345211

如果你的项目在一个地址的仓库上托管,后面想迁移到另一个地址的仓库上去,并且迁移的要求如下:
1. git 提交历史必须完全保留
2. git的各个分支和tag必须完全保留

那么可以通过下面操作完成迁移:
在新的地址上新建一个仓库,新建的仓库名字和原仓库名字保持一致就行

#clone下来旧的仓库
mkdir test
git clone http://..../..../..../test_temp    (自己旧仓库的地址)
cd test_temp

#获取所有的tag
git fetch --all

#查看所有的远程分支
git branch -a

#切换到其他的分支,把远程所有的分支都checkout到本地
#需要注意所有的分支都checkout一次
#git checkout another_branch

#添加新远程仓库,并命名为"newrepo"
git remote add newrepo https://.../.../test_temp   (新的仓库地址)

#把本地所有的分支都push到新的仓库上
git push newrepo --all

#把本地所有的tag都push到新的仓库上
git push newrepo --tags

完毕

猜你喜欢

转载自blog.csdn.net/u010221508/article/details/87345211
今日推荐