[Git] Git 仓库迁移

操作步骤
1) 从原地址克隆一份裸版本库,比如原本托管于 GitHub。

--bare 创建的克隆版本库都不包含工作区,直接就是版本库的内容,这样的版本库称为裸版本库。

2) 然后到新的 Git 服务器上创建一个新项目,比如 GitCafe。

3) 以镜像推送的方式上传代码到 GitCafe 服务器上。

-- mirror 克隆出来的裸版本对上游版本库进行了注册,这样可以在裸版本库中使用git fetch命令和上游版本库进行持续同步。

4) 删除本地代码

5) 到新服务器 GitCafe 上找到 Clone 地址,直接 Clone 到本地就可以了。

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

附注:如果你已经有一个本地的版本库,只需进入版本库地址,然后运行步骤 3)即可。

常见错误
1、Error:Permission denied (publickey).
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

如果出现如下错误,并且确定在新的版本库地址有权限,可以将上面 git@gitcafe.com/username/newproject.git 换成 https://gitcafe.com/username/newproject.git 再试下。

参考文献
[1] 转载自:https://my.oschina.net/kind790/blog/510601

Add a Comment

您的电子邮箱地址不会被公开。 必填项已用*标注