-
-
Save mandiwise/5954bbb2e95c011885ff to your computer and use it in GitHub Desktop.
// Reference: http://www.blackdogfoundry.com/blog/moving-repository-from-bitbucket-to-github/ | |
// See also: http://www.paulund.co.uk/change-url-of-git-repository | |
$ cd $HOME/Code/repo-directory | |
$ git remote rename origin bitbucket | |
$ git remote add origin https://github.com/mandiwise/awesome-new-repo.git | |
$ git push origin master | |
$ git remote rm bitbucket |
👍 @trevjonez - The import tool worked great migrating from Bitbucket.
I don't know if anyone else needs this, but I created a tool to migrate all repos from a Bitbucket organization account to Github using Github's import tool API.
https://pypi.org/project/bitbucket2github/
Thanks! Works!
This method is only moving the master branch. I would urge you to use the github built in
Import Repository
tool.
Add repo menu in top right hand corner of most screensYou can then change your local repo to point at the new origin.
git remote -v
to print the current settings
git remote set-url origin git@github.com:username/repo-name.git
to change origin to the new url (ssh style url shown here, use the https style like above if that is what you prefer.)then after that you can optionally add the old remote if you have a need.
The problem with doing a
remote rename
is that any local branches tracking origin will then track bitbucket which may or may not be desirable. Then once you doremote rm
the local branches are left with no remote tracking branch, again this may or may not be desirable.For the purpose of switching from bitbucket to github for which you won't be returning or requiring the ongoing hosting on bitbucket it would be desirable to not rename but simple reassign origin's url with the new github URL.
This is absolutely the right approach. Worked like a charm - cheers!
I followed this and it's also working fine. How to Move a Private Repository from Bitbucket to Github
👍 importing tool is great option
great solution, working for me
Same thing but with clone command, and removing $ symbols for copy paste usefulness:
git clone git@bitbucket.org:username/old-repo.git
cd old-repo
git remote rename origin bitbucket
git remote add origin https://github.com/username/new-repo.git
git push origin master
git remote rm bitbucket
Please prefer SSH to HTTPS if you want to work without entering your credentials for each push.
good solution, it worked for me
This method is only moving the master branch. I would urge you to use the github built in
Import Repository
tool.
Wow. The GitHub Import Tool is fabulous. I imported a BitBucket repository in a few seconds, without worrying that:
$ git remote rm bitbucket
Might delete my entire BitBucket account...
+1 for GitHub import tool.
If you're using bitbucket make sure the login is whatever it says in your https://bitbucket.org/account (not your email address) and generate an app password, that worked for me.
I'm not tried yet, btw what about history commit on repo after moved? will it recorded also or it will just begin from zero?
I'm not tried yet, btw what about history commit on repo after moved? will it recorded also or it will just begin from zero?
already tried & my commit histories followed. Thank you for your snippet commands
This method is only moving the master branch. I would urge you to use the github built in
Import Repository
tool. Add repo menu in top right hand corner of most screensYou can then change your local repo to point at the new origin.
git remote -v
to print the current settingsgit remote set-url origin git@github.com:username/repo-name.git
to change origin to the new url (ssh style url shown here, use the https style like above if that is what you prefer.)then after that you can optionally add the old remote if you have a need.
The problem with doing a
remote rename
is that any local branches tracking origin will then track bitbucket which may or may not be desirable. Then once you doremote rm
the local branches are left with no remote tracking branch, again this may or may not be desirable.For the purpose of switching from bitbucket to github for which you won't be returning or requiring the ongoing hosting on bitbucket it would be desirable to not rename but simple reassign origin's url with the new github URL.
Thank you so much! This worked perfectly.
Thanks, worked fine! s2
Created a small project to do this - https://github.com/searchspring/bb2gh
awesome! Worked perfectly!
If you're using bitbucket make sure the login is whatever it says in your https://bitbucket.org/account (not your email address) and generate an app password, that worked for me.
Thanks @jstxx it worked for me !
Thanks!!
wow, that was easy! thanks for help!
If you're using bitbucket make sure the login is whatever it says in your https://bitbucket.org/account (not your email address) and generate an app password, that worked for me.
Thanks this worked!
If you're using bitbucket make sure the login is whatever it says in your https://bitbucket.org/account (not your email address) and generate an app password, that worked for me.
Thanks for the tip. it worked for me!
It worked for me, thank you @mandiwise :)
If you're using bitbucket make sure the login is whatever it says in your https://bitbucket.org/account (not your email address) and generate an app password, that worked for me.
Promote this man! This was my problem :)
According to github importer documenation, the following is NOT imported:
- Personal repositories owned by users
- Branch permissions
- Commit comments
- Repository settings
- CI pipelines
This makes the import tool a non-starter for me, my bitbucket repos are all private and I very much want the commit comments.
BTW, this thread may see more activity for awhile.. Atlassian in its wisdom has terminated support for Bitbucket Server effective 5-MAR-2024 (2 weeks from now).
Please, don't follow this advice. There are multiple problems with this approach already highlighted by @trevjonez.
The best way to move a repository to GitHub is using GitHub Importer tool. Alternatively it is possible to do it from command line via cloning to bare repository.
Just follow the guidance of GitHub and you'll be fine. 😉