Search code examples
gitmergerebase

How can I remove merged commit logs?


enter image description here

Blue line is feature branch, red line is develop branch.
As you can see, develop branch was merged middle of feature branch.
And develop branch's logs were all included in feature branch.
like below

8191985 [feature] log5
62e338b [feature] log4
713d596 [feature] log3
ba94b24 Merge branch 'develop' into feature
bd751e9 [develop] log2
bec7f92 [develop] log1
7beb908 [feature] log2
5c1d36d [feature] log1

How can I clean up the develop branch's logs?
They didn't work well when I did like below..(conflict has occurred)

> git checkout feature
> git rebase develop

What thing I have to consider?


Solution

  • The question is what are you trying to achieve.

    keep all the commits on feature branch, only rebase them on top of develop branch

    In this case you did exactly right. You rebase feature branch on top of develop branch and you must resolve all conflicts.

    Squash feature branch on top of develop branch

    In this case you can avoid resolving conflicts by:

    git checkout feature
    git reset develop
    git add .
    git commit -m "All my feature changes squashed together"