/

How to Simultaneously Push to 2 Repositories and Keep Them in Sync

How to Simultaneously Push to 2 Repositories and Keep Them in Sync

If you find yourself needing to have two GitHub repositories with identical content and want to effortlessly push your changes to both, I have a solution for you. Here’s what you need to do:

  1. Start with a working repository in Git, already set up with the origin remote.

  2. Create a new empty repository on GitHub.

  3. Add the URL of the new repository as another URL for the origin remote using the following Git commands:

1
2
3
git remote set-url --add --push origin [email protected]:flaviocopes/original.git

git remote set-url --add --push origin [email protected]:flaviocopes/clone.git

That’s it! Now, whenever you perform a “git push,” your changes will be sent to both repositories simultaneously, ensuring they stay in sync.

Tag: Git, GitHub, remote repositories, synchronization