以下のワークフローでは、githubリポジトリを新しいリモートとして呼び出しsync、bitbucketリモートをとして追加しますorigin。またgithub、githubリポジトリmasterを追跡するために呼び出されるブランチと、bitbucketリポジトリを追跡するために呼び出されるブランチを追加します。空の「myrepository」というbitbucketリポジトリがあることを前提としています。
リモコンのセットアップ
# setup local repo
mkdir myrepository
cd myrepository
git init
# add bitbucket remote as "origin"
git remote add origin ssh://git@bitbucket.org/aleemb/myrepository.git
# add github remote as "sync"
git remote add sync https://github.com/aleemb/laravel.git
# verify remotes
git remote -v
# should show fetch/push for "origin" and "sync" remotes
セットアップブランチ
# first pull from github using the "sync" remote
git pull sync
# setup local "github" branch to track "sync" remote's "master" branch
git branch --track github sync/master
# switch to the new branch
git checkout github
# create new master branched out of github branch
git checkout -b master
# push local "master" branch to "origin" remote (bitbucket)
git push -u origin master
これでgithub、githubリポジトリのmasterブランチを追跡するローカルブランチが作成されました。また、ローカルmasterブランチでbitbucketリポジトリ(masterデフォルトではブランチ)を追跡する必要があります。
これにより、githubブランチをプルし、それらの変更をmasterブランチにマージし(ただし、マージよりもリベースを優先)、masterブランチをプッシュできます(ビットバケットにプッシュします)。