Skip to content

Instantly share code, notes, and snippets.

@1mursaleen
Created December 18, 2022 08:07
Show Gist options
  • Save 1mursaleen/43fa4b340878241ada20be1e4859a44d to your computer and use it in GitHub Desktop.
Save 1mursaleen/43fa4b340878241ada20be1e4859a44d to your computer and use it in GitHub Desktop.
Copying a Github repository in from one account to another (Mirroring)

If you want to mirror a repository in another location, including getting updates from the original, you can clone a mirror and periodically push the changes.

Open Git Bash.

Create a bare mirrored clone of the repository.

$ git clone --mirror https://github.com/EXAMPLE-USER/REPOSITORY-TO-MIRROR.git Set the push location to your mirror.

$ cd REPOSITORY-TO-MIRROR $ git remote set-url --push origin https://github.com/EXAMPLE-USER/MIRRORED As with a bare clone, a mirrored clone includes all remote branches and tags, but all local references will be overwritten each time you fetch, so it will always be the same as the original repository. Setting the URL for pushes simplifies pushing to your mirror.

To update your mirror, fetch updates and push.

$ git fetch -p origin $ git push --mirror

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment