关于git:整体迁移git

43次阅读

共计 1547 个字符,预计需要花费 4 分钟才能阅读完成。

本文一个 git 操作,将一个 repo 整体搬迁到另一个新建的 repo 中,包含其中的 branch/tag:
. git_test1: github.com:xiangbin1997/git_test1.git
. git_test2: github.com:xiangbin1997/git_test2.git

用 git_test1 替换 git_test2

bare 模式 clone git_test1

[postgres@hgcndn git_test1_full]$ git clone --bare git@github.com:xiangbin1997/git_test1.git  git_test1
Cloning into bare repository 'git_test1'...
remote: Enumerating objects: 19, done.
remote: Counting objects: 100% (19/19), done.
remote: Compressing objects: 100% (15/15), done.
Receiving objects: 100% (19/19), done.
Resolving deltas: 100% (2/2), done.
remote: Total 19 (delta 2), reused 13 (delta 0), pack-reused 0
[postgres@hgcndn git_test1_full]$ cd git_test1/
[postgres@hgcndn git_test1]$ ll
total 16
drwxrwxr-x 2 postgres postgres   6 Jul  8 02:48 branches
-rw-rw-r-- 1 postgres postgres 133 Jul  8 02:48 config
-rw-rw-r-- 1 postgres postgres  73 Jul  8 02:48 description
-rw-rw-r-- 1 postgres postgres  21 Jul  8 02:48 HEAD
drwxrwxr-x 2 postgres postgres 242 Jul  8 02:48 hooks
drwxrwxr-x 2 postgres postgres  21 Jul  8 02:48 info
drwxrwxr-x 4 postgres postgres  30 Jul  8 02:48 objects
-rw-rw-r-- 1 postgres postgres 210 Jul  8 02:48 packed-refs
drwxrwxr-x 4 postgres postgres  31 Jul  8 02:48 refs

减少 remote2

[postgres@hgcndn git_test1]$ git remote add remote2 git@github.com:xiangbin1997/git_test2.git

mirror 模式 push 到 remote2

[postgres@hgcndn git_test1]$ git push --mirror remote2
Counting objects: 19, done.
Compressing objects: 100% (13/13), done.
Writing objects: 100% (19/19), 2.23 KiB | 0 bytes/s, done.
Total 19 (delta 2), reused 19 (delta 2)
remote: Resolving deltas: 100% (2/2), done.
To git@github.com:xiangbin1997/git_test2.git
 + 89759c9...ab52843 main -> main (forced update)
 * [new branch]      dev -> dev
 * [new branch]      mydev -> mydev

参考
https://zhuanlan.zhihu.com/p/…

正文完
 0