I have a project in GitHub with 11 branches. This had to remain as it was while I rebuilt the project using a later version of one of the technologies.
I rebuilt the project in a private BitBucket repo. This also has 11 branches, and an entirely different commit history.
I have mirrored the original GitHub repo so that there is still public access to the 'old' code. The next step is to blow away the contents of the original GitHub repo, and replace with the contents from the BitBucket repo.
I don't want to delete / rename the GitHub repo as is has a few watchers and stars - those people should get the latest version of the code.
So the question is: how do I delete the branches and content of a GitHub repo, and replace with the branches, content and history of a different one?
Ideally I'd end up with the BitBucket version being the staging remote and GitHub the origin.
I haven't tested this myself, but according to the git push docs, you should use the --mirror flag.
git push --mirror <name of github remote>
Update: I just tested it and it seems to work as I expected. It will force your remote to look exactly like your local repository including deleting/adding branches and tags and force-updating branches.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With