Forking from GitHub to Bitbucket Forking from GitHub to Bitbucket git git

Forking from GitHub to Bitbucket


It's not possible to send "pull request" across different sites today. I've added a feature request for this in the Bitbucket issue tracker: #3288. I suggest you add yourself as a follower if you want to track this.

However, you can still move the source from GitHub to Bitbucket without having to download any zip files or tarballs. You make a clone from GitHub and push to Bitbucket:

$ git clone https://github.com/cakephp/cakephp$ cd cakephp$ git push git@bitbucket.org:mg/cakephp.git master

I created mg/cakephp as an empty Git repository in Bitbucket first. That way you can push/pull changesets from GitHub to Bitbucket.


The workflow below adds the github repository as a a new remote called sync and the bitbucket remote as origin. It also adds a branch called github to track the github repository and a branch called master to track the bitbucket repository. It assumes you have a bitbucket repository called "myrepository" which is empty.

Setup remotes

# setup local repomkdir myrepositorycd myrepositorygit 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 remotesgit remote -v# should show fetch/push for "origin" and "sync" remotes

Setup branches

# first pull from github using the "sync" remotegit pull sync# setup local "github" branch to track "sync" remote's "master" branchgit branch --track github sync/master# switch to the new branchgit checkout github# create new master branched out of github branchgit checkout -b master# push local "master" branch to "origin" remote (bitbucket)git push -u origin master

Now you should have the local github branch tracking the github repo's master branch. And you should have the local master branch tracking the bitbucket repo (master branch by default).

This makes it easy to do a pull on the github branch, then merge those changes onto the master branch (rebase preferred over merge though) and then you can push the master branch (will push it to bitbucket).


If you want to keep your repo up to date, use two remotes: Github (upstream) and Bitbucket (origin) like this:

# Clone original CakePHP source code from Githubgit clone --mirror https://github.com/cakephp/cakephpcd cakephp# Rename remote from `origin` to `upstream`git remote rename origin upstream# Add your Bitbucket repo (this is where your code will be pushed)git remote add origin https://bitbucket/your/repo.git# Push everything to Bitbucketgit push --mirror origin

To pull updates to CakePHP from Github:

git pull upstream master

To push your code changes to Bitbucket:

git push origin master