項目中遇到git倉庫遷移,很常見。如何把一個項目中全部的分支,tag等遷移到另外一個倉庫地址,須要執行一個特別的克隆命令,而後鏡像push到新的倉庫地址。具體步驟以下:
1.打開命令行工具
2.以bare的方式克隆老的倉庫git
git clone --bare https://github.com/exampleuser/old-repository.git
3.鏡像push到新的倉庫地址github
cd old-repository.git git push --mirror https://github.com/exampleuser/new-repository.git
4.在電腦中刪掉老得倉庫,把新的倉庫從新拉下來工具
cd .. rm -rf old-repository.git
原文連接命令行