This page looks best with JavaScript enabled

How to Synchronize and Back Up a Git Repository

 ·  ☕ 1 min read

Because the Git repository currently in use is about to become unavailable, the repository code needs to be migrated to a new Git repository. The specific procedure is as follows:

  1. Log in to the new repository and create a repository.

After creation, the new repository address is: http://gitlab.your-new-domain.com/project.git

  1. Clone the old repository as a mirror locally:
1
2
3
git clone --mirror  http://gitlab.your-old-domain.com/project.git
# If you only need to clone Branches and Tags, you can use --bare instead of --mirror.
cd project.git
  1. Push the mirror to the new repository
1
2
git remote set-url --push origin http://gitlab.your-new-domain.com/project.git
git push --mirror

Tips:

Update all repositories in the current directory

fetch_all.sh

1
for d in ./*/ ; do (cd "$d" && git fetch); done

Archive all repositories in the current directory

tar_all.sh

1
ls |xargs -i  tar zcvf {}.tar.gz {}

WeChat Official Account
WRITTEN BY
WeChat Official Account