1

Suppose I have Commit history as follows:

a -- b -- c                  <-- Branch1
           \
            d -- e           <-- Branch2

Now I checkout to branch1 and squash commits b and c into x.

I expected something like this to happen.

a -- x                  <-- Branch1
      \
       d -- e           <-- Branch2

But on running git log on Branch1, it shows:

a -- x

and on running git log on Branch2, it shows:

a -- b -- c -- d -- e

now even if I checkout to branch2 and squash b,c, it won't generate x but some other commit hash.

So my question is, How do I squash those 2 commits properly such that it is reflected in all branches?

Also how do I fix up once I already did that?

Raman
  • 2,735
  • 1
  • 26
  • 46

1 Answers1

4

Now I checkout to branch1 and squash commits b and c into x.

after that you still are on Branch1 do the following

git checkout Branch2
git rebase -

important note make sure before doing git rebase - you were on the branch you need to rebase. In this case it's Branch1. if you changed branches why so ever first go back to Branch1 so like this:

git checkout Branch1
git checkout Branch2
git rebase -
caramba
  • 21,963
  • 19
  • 86
  • 127