Git 仓库迁移

关于 Git 仓库 迁移的方法

迁移命令模板

  1. 镜像克隆:

    1
    2
    git clone --mirror https://github.com/../old.git old.git
    cd old.git
  2. 然后推送镜像:

    1
    2
    git remote set-url --push origin git@gitcafe.com/.../new.git
    git push --mirror
  3. 或者推送新建remote再推送:

    1
    2
    3
    git remote add mirror origin git@gitcafe.com/.../new.git
    git push mirror --all
    git push mirror --tags

project-a 迁移实例

1
2
3
4
5
6
7
$ git clone --mirror ssh://git@****:****/****/project-a.git
> 克隆到纯仓库 'project-a.git'...
> remote: Counting objects: 7012, done.
> remote: Compressing objects: 100% (8/8), done.
> remote: Total 7012 (delta 0), reused 0 (delta 0)
> 接收对象中: 100% (7012/7012), 487.89 MiB | 41.89 MiB/s, 完成.
> 处理 delta 中: 100% (2835/2835), 完成.
1
$ cd project-a.git/
1
$ git remote set-url --push origin ssh://git@****:****/****/project-a.git
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$ git push --mirror
> The authenticity of host '[server]:10090 ([172.24.***.***]:10090)' can't be established.
> ECDSA key fingerprint is SHA256:nVnsCJaQGoJh0ehUKJ2/v4YQkJIKM2VzadcoUvTyFKc.
> Are you sure you want to continue connecting (yes/no)? yes
> Warning: Permanently added '[server]:10090,[172.24.***.***]:10090' (ECDSA) to the list of known hosts.
> 对象计数中: 7012, 完成.
> Delta compression using up to 4 threads.
> 压缩对象中: 100% (3456/3456), 完成.
> 写入对象中: 100% (7012/7012), 487.89 MiB | 12.49 MiB/s, 完成.
> Total 7012 (delta 2835), reused 7012 (delta 2835)
> remote: Resolving deltas: 100% (2835/2835), done.
> To ssh://cmserver:10090/cartronics/project-a.git
> * [new branch] master -> master
> * [new branch] customer -> customer
> * [new branch] refs/keep-around/6780f93f4b5c07c2f9de9ee9f1af591b9ad1e874 -> refs/keep-around/6780f93f4b5c07c2f9de9ee9f1af591b9ad1e874

本站点采用知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议进行许可。