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:
-
Start with a working repository in Git, already set up with the
origin
remote. -
Create a new empty repository on GitHub.
-
Add the URL of the new repository as another URL for the
origin
remote using the following Git commands:
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