How to Mirror an Azure DevOps Repo to GitHub - DAV-1000/react-material GitHub Wiki
Created: 8/12/2025 11:49
Updated: 8/12/2025 11:55
Exported: 8/12/2025 13:14
Prompt:
How to push an existing git repo (created in Azure DevOps) to a new repo on GitHub
Response:
Got it — you have an existing Azure DevOps repo and you want to push it to a new GitHub repo.
Here’s the step-by-step process:
1️⃣ Create the new GitHub repository
- Go to GitHub.
- Click + → New repository.
- Give it a name, keep it empty (✅ don’t add README, license, or .gitignore).
- Copy the HTTPS or SSH URL — you’ll need it later.
2️⃣ Clone your Azure DevOps repo locally
git clone https://dev.azure.com/your-org/your-project/_git/your-repo
cd your-repo
(Replace with your actual Azure DevOps repo URL — you can find it in Azure DevOps under Clone.)
3️⃣ Remove the old Azure DevOps remote
git remote remove origin
This disconnects the local repo from Azure DevOps.
4️⃣ Add the new GitHub remote
git remote add origin https://github.com/your-username/new-repo.git
Or if using SSH:
git remote add origin [email protected]:your-username/new-repo.git
5️⃣ Push all branches & tags to GitHub
git push -u origin --all # Push all branches
git push -u origin --tags # Push all tags
✅ At this point, your Azure DevOps repo should be fully mirrored into the new GitHub repo — including history, branches, and tags.
If you want, I can also give you a one-liner "mirror" command that directly clones from Azure DevOps and pushes to GitHub in one go. This is cleaner if you don’t need the repo locally for editing.
Do you want me to give you that mirror-push version?
Prompt:
Yes
Response:
Alright — here’s the mirror-push method.
This clones your Azure DevOps repo with all branches, tags, and refs, then pushes it straight to GitHub in one shot.
Mirror Push Steps
1️⃣ Create an empty GitHub repo
Just like before — no README, license, or .gitignore.
2️⃣ Run these commands:
# Clone the Azure DevOps repo in mirror mode
git clone --mirror https://dev.azure.com/your-org/your-project/_git/your-repo
# Go into the new mirror directory (note the .git at the end)
cd your-repo.git
# Push everything to the new GitHub repo
git push --mirror https://github.com/your-username/new-repo.git
Key points:
--mirror
clones all branches, tags, refs, and hooks — even remote-tracking branches.- The
.git
folder created by--mirror
is bare (no working files). - It’s perfect for full migrations.
Do you want me to also give you the reverse command so you can keep Azure DevOps and GitHub in sync automatically? That way they both stay updated.
Prompt:
Will the mirror push command create a public or private repo
Response:
The git push --mirror
command itself doesn’t decide whether your GitHub repo is public or private — that’s entirely determined by how you set up the new repo on GitHub before running the command.
- If you created the GitHub repo as public, the mirrored code will be public.
- If you created it as private, it stays private — and only people you give access to can see it.
So the push just sends the commits and refs to whatever visibility setting you chose in GitHub.
If you want to double-check before pushing:
- Go to your new GitHub repo’s page.
- Look under the repo name — it will say Public or Private.
If you want, I can give you a quick GitHub CLI command that will create a private repo automatically and then mirror-push into it — so there’s no risk of accidentally making it public.
Powered by ChatGPT Exporter