需求
将A仓库工程的分支、标签等所有信息迁移至B仓库。
步骤
1. 克隆仓库A
给予仓库A克隆出一个裸仓库,裸仓库不包含工作区,仅包含分支、标签和版本历史等信息
git clone --bare <url_of_repository_A>
2. 进入裸仓库目录
cd <repository_A.git>
3. 添加新仓库B作为远程仓库
git remote add new-origin <url_of_repository_B>
4. 推送至B仓库
git push --mirror new-origin
5. 删除本地的裸仓库A(可选)
cd ..
rm -rf <repository_A.git>