Sync git repos between different Git git hosters
Posted in development on March 22, 2018 by Adrian Wyssmann ‐ 2 min read
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)
Now add Github repo as a new remote in Bitbucket called “sync”
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”
Now do a pull from the “master” branch in the “sync” remote
Setup a local branch called “github"track the “sync” remote’s “master” branch
Now push the local “master” branch to the “origin” remote in Bitbucket.