原文地址:https://blog.youkuaiyun.com/u010892253/article/details/86637201
背景:
我们需要将一个老的git仓库迁移到新的仓库,并且要将所有的commit history、branches、tags都迁过去。
查了很多资料,用了三种方式,在最后一种成功了,并且步骤超级简单。
实现方式:
1.从老仓库克隆一份裸版本库。
git clone --bare http://oldgithub.com/username/oldproject.git
2.在新的Git服务器上创建一个新仓库,比如叫newproject。
3.以镜像推送的方式上传代码到newproject服务器上。
cd oldproject.git
git push --mirror http://newgithub.com/username/newproject.git
4.删除本地代码
cd ..
rm -rf oldproject.git
5.切换远程仓库地址。在本地的代码仓库执行如下,即可完美过渡。
git remote set-url origin http://newgithub.com/username/newproject.git
6.如果使用了git客户端管理,只需要通过地址下拉代码就可以了。
以此记录,也希望能够帮助到更多的人。
收工。本地代码仓库可以像往常一样commit、push。