Yes, you read that correctly :). Hope this makes sense, so here's what happened:
I merged my working branch into master, per usual. My internet dropped midway through the merge and my local/working branch corrupted (workspace integrity issues). As I was trying to debug and figure out how to fix, I came across the "Revert" button on Bitbucket. So, I clicked it to see if that would solve my problem.
What I saw was that it would create a new PR "called revert pr #" which looks like it selects the previous commit (or undos the most previous commit) and merges that back into master. logically, that's fine and worked as it should.
however, I realized that actually didn't solve my workspace integrity issue, and I had to do some other stuff to fix that. once I fixed the workspace issue, I wanted to re-try merging the original PR (PR #53), but it still says "revert". I suspect that this doesn't actually "revert my revert" and instead repeats the process of creating a new PR, etc.
so rather than trying that, i tried to go back to the branch that the original PR was created for and create another PR for it. but, it's not working. despite the working branch being different from the master, it doesn't seem to let me create a new PR as it said something to the effect of "there are no changes in this branch from the master branch". so i artificially forced those changes by deleting a few comments, etc., hoping that would do something to no avail.
so now, I'm trying to figure out how to revert back my master to pre PR#53 being merged and also recreating PR #53 so that I can merge in the working branch into my master.
I hope that makes sense?
It is possible to have you changes added back to your master branch, but there are a couple of things you need to do.
Linus Torvalds explains the situation (https://mirrors.edge.kernel.org/pub/software/scm/git/docs/howto/revert-a-faulty-merge.txt):
Reverting a regular commit just effectively undoes what that commit did, and is fairly straightforward. But reverting a merge commit also undoes the _data_ that the commit changed, but it does absolutely nothing to the effects on _history_ that the merge had.
So the merge will still exist, and it will still be seen as joining the two branches together, and future merges will see that merge as the last shared state - and the revert that reverted the merge brought in will not affect that at all.
So a "revert" undoes the data changes, but it's very much _not_ an "undo" in the sense that it doesn't undo the effects of a commit on the repository history.
So if you think of "revert" as "undo", then you're going to always miss this part of reverts. Yes, it undoes the data, but no, it doesn't undo history.
So in order to get your changes back into master, you need to do this:
Hi Mikael - Thanks for the response.
I followed the steps you outlined, but as I'm trying to merge the newly created branch (SAP107v2) that I created from my original branch (SAP107) into master via the PR, it's still not reading the changes.
So in both SAP107 & SAP107V2, there are 3 files that I changed. And master (both remote and local working) don't have these changes (obviously), yet the PR isn't seeing the difference beyond a line that i commented out to force a new commit.
What am I doing something wrong? I almost feel like I should just "force push" this SAP107 or SAP107V2 to master and overwrite it since technically it has everything that I need.
Mikael, thanks a bunch for this solution.
I am in the same situation 2.5 years later and it seems that the --no-ff option was deprecated and removed from git in the meantime. I find no trace of it anymore. I will try to figure it out on my own, but if you have any Idea I appreciate every input.
@elninjagaiden you basically have to follow the lines in the output and try and figure out which of the commits is the parent one. If you only have one commit on the branch it is simple, if you have many it will take some detective work. Example:
Lets say I want to find the parent commit for bugfix/SB-60-user-scenarios-demo. If you do it from the command line, you can see it is not that easy to find it. The top screenshot is from within Sourcetree and it makes it easier to find the parent.
Hey Community! We’re willing to wager that quite a few of you not only use Bitbucket, but administer it too. Our team is excited to share that we’ll be releasing improvements throughout this month of...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events