Git Advanced: How to push to 2 repositories at the same time and keep them in sync

Join the AI Workshop to learn more about AI and how it can be applied to web development. Next cohort February 1st, 2026

The AI-first Web Development BOOTCAMP cohort starts February 24th, 2026. 10 weeks of intensive training and hands-on projects.


I had the need to have 2 GitHub repositories with the same exact content.

Whenever I pushed my changes, those changes had to be sent to those 2 repositories without any extra work.

So here’s what I did.

I already had a working repository with some code, set up as the origin remote in Git.

I created a new empty repository on GitHub, and I set it as another URL for the origin remote:

git remote set-url --add --push origin git@github.com:flaviocopes/original.git

git remote set-url --add --push origin git@github.com:flaviocopes/clone.git

That’s it. Now doing a “git push” sends the changes to both repositories.

Lessons in this unit:

0: Introduction
1: Working with Remotes
2: Squashing Commits
3: Rebase vs Merge
4: Git Bisect for Debugging
5: Git Worktrees
6: Git Submodules
7: Understanding Detached HEAD
8: Managing Secrets in Git
9: Git Workflows and Best Practices
10: ▶︎ How to push to 2 repositories at the same time and keep them in sync
11: How to update a Git branch from another branch
12: Git, detached HEAD
13: Trigger deploys on Netlify with submodules
14: A Git Cheat Sheet
15: Git, squashing vs not squashing
16: An incomplete list of great Git tutorials
17: Git, what if you forgot to add a file to a commit?
18: Git workflow to manage work on multiple branches
19: How to setup the Git SSH keys