Home Restore from a Mirror
Post
Cancel

Restore from a Mirror

Restore Repository using a Git Mirror

If you followed the guide on setting up a mirror as a real-time backup, you may now be wondering how can I restore a lost or corrupt repository using the mirror. For this how-to we will use Github (source) as the mirror and Gitlab (destination) as the repository to restore. Please Note: this method assumes whatever corrupted the source repository was not also mirrored, if that is the case, snapshots or backups are what you will want.

Option 1

  1. Copy the clone URL for the mirror - [email protected]:Sarlaac/sandbox-mirror.git
  2. Clone the copy to a temporary local repository

git clone [email protected]:Sarlaac/sandbox-mirror.git

  1. Update the remote URL to the repository you want to restore.
1
2
git remote set-url <name> <newurl> [<oldurl>]
git remote set-url origin [email protected]:sarlaac/sandbox-demo.git [email protected]:Sarlaac/sandbox-mirror.git
  1. Check that the new URL is in place.

git remote -v

  1. Push the local copy to Gitlab, restoring the repository. You may need to force-push depending on the state of the destination.
This post is licensed under CC BY 4.0 by the author.