gitmergegit-branchsquashtrunk

Git Workflow short-lived feature branch with squash


I have a questions concerned about the following git workflow:

 - checkout master
 - pull -r origin master
 - checkout new_feature
 - rebase master
 - checkout master
 - merge --squash new_feature
 - commit -m "F"
 - push origin master

Now you will end up with the following setup, assuming some commits C,D,E happened on the new_feature branch:

Master             A --B --------------- F
                    \ 
new_feature          \ -- C -- D -- E

Local Master and Origin Master pointing to F. The F commit involves C,D,E.

Now I want to delete the new_feature Branch by running:

branch -d new_feature

error: The branch 'new_feature' is not fully merged. If you are sure you want to delete it, run 'git branch -D new_feature'.

Why do I get the error here and why does git not know, that the branch has been fully merged, just with the squash command?

(even a git diff does not show any differences)


Solution

  • Well, with these commands the new_feature branch is not formally merged, in the sense that it is not a parent node of the merged commit. What git will not check is that your changes have actually been merged. You know, but for git it is not trivial to know.

    I have tried your workflow, then I have re-merged again the squashed-merged branch and then it can be deleted.

    It is actually not an error, it is a check to prevent that you lose your work.