1

I started with a similar problem as described in this question and did some rebase and merge action and in one case ended up with the following.

---a---b---c---d---   master
    \         /
     x---y---z        thebranch

I must have done something wrong when merging (given wrong SHA?), because what I needed was the following

---a---b---c---d---   master
    \     /    
     x---y---z        thebranch

My question is now, how can I achieve this? Are grafts the way to go for or is there more straight-forward?

Community
  • 1
  • 1
moxn
  • 1,790
  • 1
  • 15
  • 34
  • So, "c" was a normal commit which you want to be a merge of "y" instead? – che Dec 20 '12 at 10:22
  • @che Yes, correct. The repo was migrated from SVN to Git, which may explain the not so Git-like state of it. – moxn Dec 20 '12 at 10:29

3 Answers3

0
  1. Go to master branch.

    git checkout master

  2. I presume d is a merge commit. So, we can discard it.

    git reset --soft c //it brings your master branch back to c.

  3. Merge y now.

    git merge y

Karthik Bose
  • 33,556
  • 3
  • 33
  • 43
0
$> git checkout master           # go to master
$> git reset --hard c            # roll back to c, discarding the merge-commit d
$> git merge y                   # merge y into c, creating a new merge-commit d'

by doign that

---a---b---c---d---   master
    \         /
     x---y---z        thebranch

effectively becomes

---a---b---c---d'---      master
    \         /    
     x-------y---z        thebranch
Nils Werner
  • 34,832
  • 7
  • 76
  • 98
0
git checkout -b by b
git merge y

This should get you

---a---b---by---    by
    \     /
     x---y---z      thebranch

git checkout master
git reset --hard c

This should get you

         c -- master
        /
---a---b---by---    by
    \     /
     x---y---z      thebranch

git rebase --onto by HEAD^
git branch -d by

This should get you:

---a---b---by---c'    master
    \     /
     x---y---z      thebranch

...i think :-)

che
  • 12,097
  • 7
  • 42
  • 71