Git: Save to both Github and Bitbucket at the same time
I have git repo living on Amazon CodeCommit but I want to save backups on Github or Bitbucket. Here's how:
Step 0 - Change Directory
First change directories to the git repo on your local drive.
cd /path/to/git/repo/
Step 1 - Add Bitbucket as a remote backup
You can create a remote git url by adding remote
. In this example, I created a repo on bitbucket with an alias "mybitbucket".
git remote add mybitbucket git@bitbucket.org:chrisjmendez/repo.git
Step 2 - Add Github as a second remote backup
git remote add set-url mygithub git@github.com:chrisjmendez/repo.git
Step 3 - Business as usual
Now that you've added two remote backups, you can continue business as usual.
git add -A
git commit -m 'my commit message'
git push
Step 4 - Push to a specific repo
If you want to specifically push to your github repo.
git push -u mygithub
Step 5 - To origin an all remote backups
Push to all repos.
git push -u --all