I want to migrate an old Bitbucket repository, containing multiple branches, to Github. To accomplish this, I've followed this description:
# add remote github repository
$ git remote add upstream https://github.com:USER/PROJECT.git
# push all branches <-- doesn't work
$ git push upstream master
$ git push --tags upstream
Only the master
branch is pushed to the Github repository (also for git push --all upstream
).
In order to push all branches to Github, I need to checkout
them individually and do git push upstream
.
How can I push all branches to Github without first checkout
them?
You can do it by using this single command.
git push REMOTE --mirror
You can read more about it here
Follow the below steps.
Mirror the source repo.
git clone --mirror https://url-of-the-source-git-repo.git
Go to the newly cloned repo
cd to-your-git-repo-folder.git
set the new remote url.
git remote set-url --push origin https://url-of-the-destination-git-repo.git
Push to the new repo
git push --mirror
By following these commands you will migrate to new repo with all the branches and commits.
First make sure that you have fetched all branches .
git fetch --all
Then push all branches to the new remote
git push upstream --all
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.