Skip to content

Instantly share code, notes, and snippets.

@sgmeyer
Last active August 5, 2016 11:57
Show Gist options
  • Save sgmeyer/08dd70ab28fca53aeaef6de028918eba to your computer and use it in GitHub Desktop.
Save sgmeyer/08dd70ab28fca53aeaef6de028918eba to your computer and use it in GitHub Desktop.
Adds a remote repository to an existing repository. This can be used for transferring repositories to multiple Git providers. It can also be useful for sharing code.
# Adds a remote called 'github' to your repository
git remote add github https://github.com/your_username/your-git-repository.git
# Bare, mirrored push to 'github' remote repository
git push -mirror github
# clone a bare, mirrored repository
git clone --mirror https://github.com/your_username/your-git-repository.git
# Change origin to new URL
git remote set-url --push origin https://github.com/your_username/your-git-repository.git
# Push repository to new origin and retain history
git push --mirror
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment