This is a very simple post detailing how to mirror a repo to a new account. I have repositories under other github accounts and on private git servers that I wanted to consolidate.
git clone --mirror URL/REPO.git
Clone the repo with a
--mirrortag. This will create a
Create a new repository on the server you would like to mirror to, lets call the address to this:
NEW-REPO-URL. Note: the new repository doesn’t have to have the same name.
- Change to the newly mirrored repo
git remote set-url --push origin NEW-REPO-URL
- Add the address to the new repo as a remote origin
git push --mirror
- Push the repo to the new server/account.
All the branches and commit history should be available in the new repository. However, I did notice that some repositories that I mirrored from GitHub Enterprise servers had my username as
GitHub Enterprise. Unsure of how to fix that for now, but it isn’t a deal breaker for my particular use case.