简体   繁体   中英

Moving repository from one git instance to another along with all commit and branch histories

We are maintaining our code in a repository hosted on a self-managed gitlab instance. We have several branches and commits. Now we have a new gitlab instance. We want to move over repository to this new gitlab instance including all commits and branches. I checked the git lab doc and I found their backup and restore option . Also this says:

To migrate from an existing self-managed GitLab instance to a new self-managed GitLab instance, it's best to back up the existing instance and restore it on the new instance. For example, this is useful when migrating a self-managed instance from an old server to a new server.
The backups produced don't depend on the operating system running GitLab. You can therefore use the restore method to switch between different operating system distributions or versions, as long as the same GitLab version is available for installation.

But this seem to be elaborate procedure. Is this the only way to do what we wish to do? Or is there any smaller procedure / set of commands to achieve the same?

Gitlab has a database which stores stuff that is not part of the git repository: users (+ ssh keys), issues and merge requests, repository rules (protected branches, ...), gitlab hooks...

If you care about those, you should definitely follow Gitlab's guide.


If you just want to move the commits and branches from one repo to another, this should be a simple:

git clone --bare --mirror <oldrepo>
cd <repo_directory>
git push --all <url_of_newrepo>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM