Last active
December 24, 2021 21:50
-
-
Save apristen/95f550b7bf6e248103be2cb6637a746f to your computer and use it in GitHub Desktop.
How to move repo from one git to another with all branches and commits, for example from Bitbucket to GitHub.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# see https://www.devopsschool.com/blog/how-to-move-repository-from-bitbucket-to-github-with-all-branches-and-commits/ | |
# see https://stackoverflow.com/questions/10312521/how-to-fetch-all-git-branches | |
# git clone [email protected]:source_project_name/source_repo.git # for SSH | |
git clone https://[email protected]/source_project_name/source_repo.git # for HTTPS | |
cd source_repo | |
git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done | |
git fetch --all | |
git pull --all | |
# all source repo should be cloned totally at this point :-) | |
# git remote add upstream [email protected]:destination_project_name/destination_repo.git # for SSH | |
git remote add upstream https://github.com/destination_project_name/destination_repo.git # for HTTPS | |
git push upstream --all | |
git push --tags upstream | |
git remote set-url origin [email protected]:destination_project_name/destination_repo.git # for SSH | |
# git remote set-url origin https://github.com/destination_project_name/destination_repo.git # for HTTPS | |
git push --mirror |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment