Automatic Sync 2 Remote Git Repositories

A simple script for synching 2 remote Git repositories

I’ve searched the web for a simple script that will sync. 2 remote repositories but I couldn’t find such script even that many seems to look for it! So I’ve created 2 simple test repositories and started testing and building such script.

What such script should do?

Well, in general, the steps for doing it are simple:

  1. Clone the first repository
  2. Add the second one as an additional remote repository
  3. fetch all there is in the second repository
  4. push the updated local repository onto the 2 remote repositories.

The remained issue is - what are the correct switches for all the above git commands?

So here it is… gisp script -


# REPO_NAME=<repo>.git
# ORIGIN_URL=git@<host>:<project>/$REPO_NAME
# REPO1_URL=git@<host>:<project>/$REPO_NAME

rm -rf $REPO_NAME
git clone --bare $ORIGIN_URL
git remote add --mirror=fetch repo1 $REPO1_URL
git fetch origin --tags
git fetch repo1 --tags
git push origin --all
git push origin --tags
git push repo1 --all
git push repo1 --tags

NOTE - this script is not solving cases of conflicts between the repository content!

Enjoy (and don’t forget to feedback!),

Yoram Michaeli

Thank you for your interest!

We will contact you as soon as possible.

Send us a message

Oops, something went wrong
Please try again or contact us by email at