git migration repository

Requirement: There is a project that was originally placed on the git of server A, and now it needs to be migrated to server B, and all submission records need to be kept.
Both servers use locally installed gitlab.
It doesn’t matter if the members contained in the two servers are different. , can lead to the past

Test process:
Method 1:
Enter the gitlab interface, select new project, and then select import project.
insert image description here
There are two ways to import, one is Repo by URL, you need to have corresponding permissions, you need 2 servers to communicate, and directly enter the old git of the project The git address on the server will do.
The other is to export the project from the old server, then use GitLib export, enter the project name, and then select the exported compressed package.
How to export it?
gitlab export insert image description here
insert image description here
After you click the export button, you will be prompted to receive an email. If you have not configured a mailbox, or the local area network has basically released an email, at this time, after the export is complete, refresh the page and you can see the download button to download directly. That's fine. If the project is relatively large and you don’t know when it will be imported, you can refresh it later
insert image description here
Method 2:
Use the command line:
(1) Clone a bare repository from the original address

git clone --bare git://aaa.com/username/project.git

git://aaa.com/username/project.git in the above command refers to the old git address of the project

The cloned repository created by –bare does not contain a workspace, and is directly the content of the repository. Such a repository is called a bare repository.
(2) Create an empty project from the new git server
(3) Upload the code to the new git server by mirror push

cd project.git 
git push --mirror [email protected]/username/newproject.git

In the above command, cd project.git is the version library that we git cloned in the first step. It is the address behind the folder
git push --mirror. It is the git address of the newly created project on the new git service, which is what we want to import The address of
the main git push also requires corresponding permissions, otherwise an error will be reported

$ git push --mirror [email protected]:group/project.git
Counting objects: 64, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (36/36), done.
Writing objects: 100% (64/64), 56.90 KiB | 0 bytes/s, done.
Total 64 (delta 12), reused 64 (delta 12)
remote: GitLab:
remote: A default branch (e.g. master) does not yet exist for group/project
remote: Ask a project Owner or Maintainer to create a default branch:
remote:
remote: http://git.bbb.com/group/project/project_members
remote:
To [email protected]:group/project.git
! [remote rejected] dev -> dev (pre-receive hook declined)
! [remote rejected] master -> master (pre-receive hook declined) .0.190630_release (pre-receive hook declined)
error: failed to push some refs to ‘[email protected]:group/project.git’

After executing git push, it is successfully uploaded to the new git, and the cloned bare version library can be deleted.

Then clone the project from the new git address, and you can continue to use it.

Guess you like

Origin blog.csdn.net/small_tu/article/details/94722716