Wieder was gelernt

Reset Master in Bitbucket

Tags: git bitbucket
2020-09-22

Assumption: The last few commits on master were erroneous and should be discarded.

Create a fresh clone of the repo

Create a new branch at the last good commit:

git co 123456
git co -b new_master

Rename old master:

git branch -m master old_master

Push to repo:

git push --all

In Bitbucket, change the default branch in Settings -> Repository details

Now the master branch can be deleted. (If there are still pull requests targeting master, you will get an error message: Edit those PRs and redirect them to new_master)

Again on your local repo, create a new master branch:

git co new_master
git co -b master

and push it:

git push

Now we have a master again, so me make it the default branch.

To avoid confusion, remove all local repositories and clone them again.