Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to sync a git repo to a mirrored repo

I want to mirror a git repo to my local repo, and wish to timely sync them, I did like this:

git clone --mirror source_url source_repo
cd source_repo
git push --mirror local_url

Now I have mirrored the source repo to my local repo, I could clone my local repo like this:

git clone local_url local_repo

But since the source repo is going update, how could I keep them sync?

like image 325
Richardicy Avatar asked Jan 02 '18 02:01

Richardicy


People also ask

How do I mirror an entire existing Git repository into a new one?

You first have to get the original Git repository on your machine. Then, go into the repository. Finally, use the --mirror flag to copy everything in your local Git repository into the new repo.


2 Answers

Any local repository, either mirrored or working, can be synced with git remote update

cd REPO
git remote update
like image 159
max630 Avatar answered Oct 11 '22 09:10

max630


Exactly for this purpose I created git-sync-mirror.

git-sync-mirror

A simple synchronization container image for git repositories over HTTPS

Features:

  • Authentication with https tokens
  • If needed, use a different HTTPS Proxy for source and destination
  • TLS-Trust On First Use: Seamlessly run this container behind a https scanning proxy
  • Skip certificate checks (don't do that)
  • Configure time to sleep between synchronization attempts

Usage

$ docker run \
   --rm \
   --env SRC_REPO=source \
   --env DST_REPO=destination \
   --env SLEEP_TIME=30s \
   enteee/git-sync-mirror

Note: The container is designed for synchronization over https with supported authentication using access tokens. For example replace source with https://github-user:[email protected]/Enteee/git-sync-mirror.git

like image 35
Ente Avatar answered Oct 11 '22 09:10

Ente