Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Two solutions for git warehouse migration are explained in detail

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

The method of migrating Git Warehouse without losing log

If the original commit record is required to be retained, how should it be migrated?

At the same time, the local clone the original warehouse, to be configured as a new warehouse address, how to modify it?

Note: if you use the code review tool Gerrit, you need to turn off Gerrit before performing the operation, and then open an account with Gerrit after a successful recovery.

1. Use git push-- mirror

Let's learn about some basic parameters of git.

Git clone-bare

GIT-CLONE (1) Git Manual GIT-CLONE (1) NAME git-clone-Clone a repository into a new directorySYNOPSIS git clone [--template=] [- l] [- s] [--no-hardlinks] [- Q] [- n] [--bare] [--mirror] [- o] [- b] [- u] [--reference] [--depth] [--recursive] [- []-- bare Make a bare GIT repository. That is, instead of creating and placing the administrative files in / .git, make the itself the $GIT_DIR. This obviously implies the-n because there is nowhere to check out the working tree. Also the branch heads at the remote are copied directly to corresponding local branch heads, without mapping them to refs/remotes/origin/. When this option is used, neither remote-tracking branches nor the related configuration variables are created.git push-mirror--mirror Instead of naming each ref to push, specifies that all refs under refs/ (which includes but is not limited to refs/heads/, refs/remotes/, and refs/tags/) be mirrored to the remote repository. Newly created local refs will be pushed to the remote end, locally updated refs will be force updated on the remote end, and deleted refs will be removed from the remote end. This is the default if the configuration option remote..mirror is set.

1. Set up a new warehouse

1)。 Clone a naked version library from the original address, such as a GitHub hosted or a local private repository

Git clone-bare git://192.168.10.XX/git_repo/project_name.git

2)。 Then create a new project on the new Git server, such as GitCafe, or a local private repository, such as 192.168.20.XX

Su-gitcd / path/to/path/mkdir new_project_name.gitgit init-- bare new_project_name.git

3)。 Upload the code to the GitCafe server in the way of mirror push.

Please make sure that the public key has been added to the new machine

Cd project_name.gitgit push-mirror git@192.168.20.XX/path/to/path/new_project_name.git

4)。 Delete local code

Cd.. rm-rf project_name.git

5)。 Find the Clone address on the new server and Clone it locally.

Git clone git@192.168.20.XX/path/to/path/new_project_name.git

In this way, everything in the original library can be preserved.

2. Switch remote_url

Check the name of remote first.

Git branch-r

Suppose your remote is origin, change your address with git remote set_url

Git remote set-url origin remote_git_address

Change remote_git_address to your new warehouse address.

The second way to switch remote_url is more straightforward, just change the ip address in the .git / conf configuration file.

The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report