AI Workshop: learn to build apps with AI →
Git Advanced: How to push to 2 repositories at the same time and keep them in sync

Join the AI Workshop and learn to build real-world apps with AI. A hands-on, practical program to level up your skills.


I needed to have two GitHub repositories with the same exact content.

Whenever I pushed my changes, those changes had to be sent to those two 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 running 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 set up the Git SSH keys