How to mirror a repository

Well, It’s not actually mirror. It’s just “How to push to multiple repos but only fetch changes from one”.

Initialize a repository as always:

git init
git add README.md
git commit -m "add readme.md"
git branch -M main
git remote add origin $MAIN_REPO_URL
git push -u origin main

Add “only push” remotes:

git remote set-url --add --push origin $MAIN_REPO_URL
git remote set-url --add --push origin $MIRROR_REPO_URL
Tags: