Home > Blockchain >  Why does git-flow create a merge commit for my rebased branch
Why does git-flow create a merge commit for my rebased branch

Time:08-30

I'm using git-flow and have rebased my feature branch with the develop branch. However, when I try to finish the branch (git flow feature finish tests), git wants to create a merge commit. When I look at the git log, it clearly shows that I have two commits on the feature branch past the last commit on the develop branch, so I expected a fast-forward merge with no merge commit. Can some one explain why this isn't the case? And is there a way to avoid the merge commit?

Here's the feature branch log

$ git log
commit 8e17db0ca47e265d546051c0a0c5ade5a725bbeb
Author: user <[email protected]>
Date:   Mon Aug 29 15:12:43 2022 -0400

    feat: Unit test additions
    

commit 5d33db55b9366db0e92646471919aafa52cfb1e6
Author: user <[email protected]>
Date:   Mon Aug 29 14:24:54 2022 -0400

    feat: Improvements to processor shutdown
    

commit 7bd8d62ac6757a6e5ed92ffa114f5367416a6dfd
Author: user <[email protected]>
Date:   Mon Aug 29 12:06:43 2022 -0400

    fix: Fix warnings for unused parameters

And the develop branches log

$ git log develop
commit 7bd8d62ac6757a6e5ed92ffa114f5367416a6dfd
Author: user <[email protected]>
Date:   Mon Aug 29 12:06:43 2022 -0400

    fix: Fix warnings for unused parameters

The flow rebase command shows the feature branch as up to date.

$ git flow feature rebase
Will try to rebase 'tests'...
Current branch feature/tests is up to date.

I'm using git version 1.8.3.1

CodePudding user response:

The Git flow workflow model always creates merge commits, and does not use fast-forward merges (unless the feature has just 1 commit; see @TTT's comment). That's because the merge commit documents where these commits come from.

Ref: https://jeffkreeftmeijer.com/git-flow/ :

Internally, git-flow used git merge --no-ff feature/authentication to prevent losing historical information about your feature branch before it is removed.

  • Related