O fluxo de trabalho abaixo adiciona o repositório do github como um novo controle remoto chamado synce o bitbucket remoto como origin. Ele também adiciona um ramo chamado githubpara rastrear o repositório do github e um ramo chamado masterpara rastrear o repositório de bitbucket. Ele pressupõe que você tenha um repositório de bitbucket chamado "myrepository" que está vazio.
Remotos de instalação
# 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
Ramos de instalação
# 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
Agora você deve ter a githubfilial local rastreando a filial do repositório do github master. E você deve ter a masterfilial local rastreando o repositório de bitbucket ( masterfilial por padrão).
Isso facilita fazer um puxão na githubramificação, depois mesclar essas alterações na masterramificação (embora seja preferível rebase antes da mesclagem) e você pode empurrar a masterramificação (empurrará para bitbucket).