整体迁移git

Posted 黑暗森林

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了整体迁移git相关的知识,希望对你有一定的参考价值。

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

以上是关于整体迁移git的主要内容,如果未能解决你的问题,请参考以下文章

如何整体迁移git库到另外的远程仓库(gerrit)

如何整体迁移git库到另外的远程仓库(gerrit)

如何整体迁移git库到另外的远程仓库(gerrit)

项目上线整体流程

VSCode自定义代码片段——git命令操作一个完整流程

使用实体框架迁移时 SQL Server 连接抛出异常 - 添加代码片段