Gitlab project migration

This article describes migrating projects from one group to another on GitLab. Statement: with reference to the original https://www.jianshu.com/p/902… A more reasonable supplement is made on the basis of the original text

1. Clone the project to be migrated locally first

Git clone [email protected]

2. Add new remote host address

First the CD enters Clone into the local project

Git remote add gitlab [email protected] git remote add gitlab [email protected]

The above command adds a host address named gitlab for the new project (the migrated project)

Bug: If you want to set the new host address to Origin, it will report that Origin already exists, because your localhost address may be Origin.

3. Push the master branch to the new warehouse

git push -u gitlab master

This step pushes the local master branch to the GitLab host

4. Push all branches

In the previous step we pushed the master branch, and then we pushed the other branches to the new repository

git branch -a

Check out all remote branches with git branch-a before pushing, and then check them out locally.

git checkout -b dev origin/dev

This step is the remote dev branch of checkout, named locally as the dev branch, and switched to the local dev branch. Remote may also include branches such as feature, release, etc. You need to perform the previous step, checkout, to local. The master branch has been pushed to the new repository, so there is no need to perform this step. Finally, the command is executed to push all branches

git push --all gitlab

5. Push all Tags

git push gitlab --tags

In this way, we have migrated the project code, branch, and tag all to a new project under another group.