Skip to content

Instantly share code, notes, and snippets.

@derick-montague
Last active March 11, 2024 09:36
Show Gist options
  • Star 50 You must be signed in to star a gist
  • Fork 15 You must be signed in to fork a gist
  • Save derick-montague/534572db76b30d9d9fd97c10b7aaf61d to your computer and use it in GitHub Desktop.
Save derick-montague/534572db76b30d9d9fd97c10b7aaf61d to your computer and use it in GitHub Desktop.
Sync github repo to bitbucket repo

Set up remotes

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**

Set up Branches

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

https://stackoverflow.com/questions/8137997/forking-from-github-to-bitbucket

@ingjavierpinilla
Copy link

Thank you very much!

git pull sync did not work since I had not created any branch so just using git branch --track github sync/master was enough

@Megha0894
Copy link

Thanks for the steps. Can you please help with the steps to fetch particular version of github repo and push it to our local bitbucket?
For example: If we need to fetch https://github.com/strace/strace v5.13 and push it to our local bitbucket repo, how the above steps can be modified?

@manota01
Copy link

Thanks.

@nidusbyte
Copy link

Thank you very much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment