Gerrit
Gerrit

Reputation: 435

Cannot merge after git revert -m 1

I accidentially merged the branch dev into the branch master and did push.

Master was behind dev some commits ~169.

I'm no expert in git so I read up a bit on how to revert a merge and tried git revert -m 1 which looked good. Master doesn't contain the changes dev contains.

Also those changes have been pushed to remote.

So first I thought all went well...

But then I recognized it's not possible to merge dev into master again to get those changes to master which now is needed (after a successful release). This means when I do the merge from dev to master git doesn't recognize any changes on master...

I'm really confused and hope someone can help me with this huge problem.

Thanks in advance! Gerrit

Edit: would a git reset --hard "commit before merge" solve this problem?

Upvotes: 1

Views: 2074

Answers (2)

Gerrit
Gerrit

Reputation: 435

I did solve this by doing a git reset --hard . And I think if there are no other commits in the history than the wrong one that one wants to get rid of this is the easiest solution as ending up with reverting reverts is really confusing.

Upvotes: 0

exussum
exussum

Reputation: 18558

Your branch was merged successfully into master

You then reverted the changes out

From the dev branch point of view everything is up to date. You just decided to change it later on.

If you want the changes back you will need to revert your revert commit. Find the sha1 in git log and simply do

Git revert {sha1 found}

Upvotes: 3

Related Questions