Github or Gitlab are cool and you can find really nice projects.But in a company environment you may not necessarily use Github or Gitlab, especially if you want to host your code internally - even so they support on-premise installations as well. So in certain cases you may want to "synchronize" between different hosters e.g. Bitbucket (internally) and Github (Internet).

As it is best practice you best fork the required repo into your own space or your enterprise space. Then follow the steps described in http://stackoverflow.com/questions/8137997/forking-from-github-to-bitbucket.

Go to internal git e.g. Bitbucket and create a new repository (its better to have an empty repo)

[[email protected] ~]$ git clone [email protected]/scm/testproject/myforkedrepo.git
[[email protected] ~]$ cd myforkedrepo

Now add Github repo as a new remote in Bitbucket called "sync"

[[email protected] ~]$ git remote add sync [email protected]:def/originalrepo.git

Verify what are the remotes currently being setup for "myforkedrepo". This following command should show "fetch" and "push" for two remotes i.e. "origin" and "sync"

[[email protected] ~]$ git remote -v

Now do a pull from the "master" branch in the "sync" remote

[[email protected] ~]$ git pull sync master

Setup a local branch called "github"track the "sync" remote's "master" branch

[[email protected] ~]$ git push -u origin master

Now push the local "master" branch to the "origin" remote in Bitbucket.

[[email protected] ~]$ git push -u origin master