1

I have the following situation:

A---B--- ... ---E---------------------------.
                                             \
                  A---B--- ... ---E---F---G---H---I--- ... ---N   master

I want to remove the duplicated commits from the history and remove this bad reference.

A---B--- ... ---E---F---G---H---I--- ... ---N   master

I've tried it with git rebase -i and remove the duplicate commits but this duplicate the commits again and results to a lot of merge conflicts.

f00860
  • 3,486
  • 7
  • 41
  • 59
  • wouw, those lines really looks like smoothly bending :P +1 – KurzedMetal May 31 '12 at 19:47
  • Can you please explain what do you mean with "rebase makes it even worse"?, if you wanna do what you say you'll have to rewrite everything since E including H I J (even if you don't change their content, they'll have to change their parents). There's no way you can escape that. I don't know how do you even got to that point. – KurzedMetal May 31 '12 at 19:56
  • I've corrected the graphs, thanks. – f00860 May 31 '12 at 20:17

1 Answers1

1

You can try:

git checkout -b temp E
git cherry-pick F..N
git branch -D master
git branch -m temp master

If you don't understand what you're doing, I suggest you read the manual pages of all the commands involved. The git manpages are very nice and accessible.

Artefact2
  • 7,516
  • 3
  • 30
  • 38
  • I've made some mistakes in the graph. The problem is, that there are a lot of commits, not only `F G H I J` and cherry-pick can't handle a range of commits. – f00860 May 31 '12 at 20:20
  • You can cherry-pick a range of commits. See: http://stackoverflow.com/questions/1994463/how-to-cherry-pick-a-range-of-commits-and-merge-into-another-branch – Artefact2 May 31 '12 at 20:48