The branch '…' is not fully merged

Steps to reproduce:

  • clone a repo from GitLab
  • create feature branch
  • create feature
  • push feature branch to GitLab
  • create merge request
  • get the feature branch merged into master
  • pull the updated master branch
  • try to delete the feature branch using: git branch -d feature_branch

Expected behaviour:

Deleted branch feature_branch (was 30f4ecd).

Actual behaviour:

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

Why does Git not recognize that the feature branch is fully merged?

1 Like

So, the reason is that when GitLab merges the feature branch, it re-writes history, so all the commit hashes on that branch are different to the ones on your local copy. If you say git branch -D feature_branch you’ll be OK.

Personally, I use a git alias called bdone from this blog post which at least shows me the branches that have been deleted on the GitLab, then I delete them manually from my local copy with git branch -D.

Cheers,

Sarah

1 Like

Thanks for the explanation and the link to the list of useful git aliases :+1:

2 Likes