本文一个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/...


黑暗森林
12 声望2 粉丝

弱小和无知不是生存的障碍,傲慢才是!