1

I did something stupid similar to this question: Stackoverflow question

Let me summarize it quickly:

I created a branch1 from master - did some changes - then created a different branch2 from master to do a hotfix - then i did a rebased branch1 onto the hotfix/master - and I got duplicate commits in my branch1.

Now I know i should've merged it - but how can I undo these changes? Here's a Picture of how it looks - the red rectangles are the duplicates.

Commits of my branch1

Community
  • 1
  • 1
Paparis
  • 906
  • 2
  • 9
  • 23
  • I'd appreciate a comment form the downvoter to why? – Paparis Apr 18 '17 at 14:51
  • Possible duplicate of [Git commits are duplicated in the same branch after doing a rebase](https://stackoverflow.com/questions/9264314/git-commits-are-duplicated-in-the-same-branch-after-doing-a-rebase) – Whymarrh Jul 11 '18 at 18:29

2 Answers2

2
git checkout 2536bae
git branch branch1 -f
git push origin branch1 -f

Then inform colleagues that they should throw away their branch1 and pull it anew. If they also have made commits, they can fix the issue by cherry picking their own commits after getting your fixed version and proceeding as usual.

AnoE
  • 8,048
  • 1
  • 21
  • 36
0

git reset --hard 54a69ae git merge -m "merging" f072912

eftshift0
  • 26,375
  • 3
  • 36
  • 60
  • This didn't work for me - I still had duplicate commits and wasn't able to push – Paparis Apr 18 '17 at 15:17
  • Not being able to push makes sense, you would be trying to push a history that is not ¨merged¨into the existing history of the remote branch (if you have already pushed what you showed us on the screenshot) so you will have to push --force. However I do not see how by using the two commands I provided you would end up with duplicate commits. – eftshift0 Apr 18 '17 at 15:38