El siguiente flujo de trabajo agrega el repositorio de github como un nuevo control remoto llamado syncy el control remoto bitbucket como origin. También agrega una rama llamada githubpara rastrear el repositorio de github y una rama llamada masterpara rastrear el repositorio de bitbucket. Se supone que tiene un repositorio de bitbucket llamado "myrepository" que está vacío.
Configurar controles remotos
# 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
Configurar ramas
# 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
Ahora debe hacer que la githubsucursal local rastree la mastersucursal del repositorio de github . Y debe hacer que la mastersucursal local rastree el repositorio de bitbucket ( mastersucursal por defecto).
Esto hace que sea más fácil tirar de la githubrama, luego fusionar esos cambios en la masterrama (sin embargo, se prefiere rebase sobre la combinación) y luego puede empujar la masterrama (la empujará a bitbucket).