I already have a solution for my question below.
From my local CLI, I performed a push -> the branch was there again. Then, I merged it into the correct branch. I might live a few years less, but it's okay now.
====================================================
"I have a question about reverting a merged branch that I also closed through the GUI in Bitbucket.
I had three branches:
I merged and closed 'project-name' into 'master.' I didn't do this via a pull request but directly through the branches menu on the left-hand side. I entered the branch itself and clicked the three dots where it says 'merge' in the menu. In the popup window, I clicked the checkbox where it says 'Close source branch.' Then I hit the merge button, and everything merged.
The mistake I made is that I merged it into the wrong branch. I wanted to merge it into the 'craft' branch because 'master' is way behind, and I did not use it anymore. Don't ask me why.
Locally, there aren't any changes yet because I did not perform a pull on the CLI. So everything still works there, but I have messed up my commits.
Is there a way to revert this mistake?"
I'm afraid to cause more damage, so I haven't attempted anything after I noticed my mistake.
Hi Frank!
On the master branch, do you see 1 single merge commit with all changes from project-name?
If that's the case you can use the git revert command: https://www.atlassian.com/git/tutorials/undoing-changes/git-revert
It is the cleanest way to do this. You could also merge your local branch to master (becasue you did not pull yet) and perform a force push overwriting everything on master but this is not very safe in my opinion.
To be safe: clone the repostory in another directory on your PC in order to avoid any losses in your other directory where you did not pull yet.
git clone <your repo URL>
git checkout master
git log #this will show you the latest commit. You need to find the commit ID of the merge commit
git revert -m 1 <merge_commit_ID>
git push
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.