Skip to content

Instantly share code, notes, and snippets.

@miztiik
Last active December 26, 2023 13:22
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
  • Save miztiik/647c3b67a9c3c3e8a5c857436a59477f to your computer and use it in GitHub Desktop.
Save miztiik/647c3b67a9c3c3e8a5c857436a59477f to your computer and use it in GitHub Desktop.
Adding multiple remote url to git repo

Add Multiple Remotes URLs to git

Adding the first remote origin

git remote add origin remote_1_url
git remote set-url origin remote_1_url

# Set the default remote branch for the current local branch
git branch --set-upstream master
# or
git push -u origin master

Adding the second remote codecommit

git remote add codecommit remote_2_url
git remote set-url --add --push codecommit remote_2_url

Adding the common remote all - Allows us to push both at the same time

git remote add all remote_1_url
git remote set-url --add --push all remote_2_url
git remote set-url --add --push all remote_1_url

Pushing to remotes

# To origin
git push origin master

# To repo-2
git push repo-2 master

# To ALL
git push all master

Remove remote Urls

git remote rm {{REMOTE-NAME}}
References
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment