Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save MuttakinHasib/fd26601e4c17bf4b25155a32d451714a to your computer and use it in GitHub Desktop.
Save MuttakinHasib/fd26601e4c17bf4b25155a32d451714a 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