github代码仓库转移 方法二

1、建立新仓库

  • 1). 从原地址克隆一份裸版本库,比如原本托管于 GitHub,或者是本地的私有仓库
git clone --bare git://192.168.10.XX/git_repo/project_name.git
  • 2). 然后到新的 Git 服务器上创建一个新项目,比如 GitCafe,亦或是本地的私有仓库,如192.168.20.XX
su - git
cd /path/to/path/
mkdir new_project_name.git
git init --bare new_project_name.git
  • 3). 以镜像推送的方式上传代码到 GitCafe 服务器上。
    请确保已经添加了公钥到新的机器上
cd project_name.git
git push --mirror [email protected]/path/to/path/new_project_name.git
  • 4). 删除本地代码
cd ..
rm -rf project_name.git
  • 5). 到新服务器上找到 Clone 地址,直接Clone到本地就可以了。
git clone [email protected]/path/to/path/new_project_name.git

这种方式可以保留原版本库中的所有内容。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章