git如何完整迁移仓库

如何完整迁移 git 仓库到另一个远程地址。

项目中遇到 git 仓库迁移,很常见。如何把一个项目中所有的分支,tag 等迁移到另一个仓库地址,需要执行一个特别的克隆命令,然后镜像 push 到新的仓库地址。具体步骤如下:
1. 打开命令行工具
2. 以 bare 的方式克隆老的仓库

git clone --bare https://github.com/exampleuser/old-repository.git

3. 镜像 push 到新的仓库地址

cd old-repository.git
git push --mirror https://github.com/exampleuser/new-repository.git

4. 在电脑中删掉老得仓库,把新的仓库重新拉下来

cd ..
rm -rf old-repository.git

 

 

转自:https://zhuanlan.zhihu.com/p/617916380

posted @ 2023-06-06 13:35  安静的女汉纸  阅读(262)  评论(0编辑  收藏  举报