warning: deleting branch ‘old_branch’ that has been merged to ‘refs/remotes/origin/old_branch’, but not yet merged to HEAD: why I hate/love git

git is immensely powerful. In the same way that English is as a language. There are endless nuances.

I love that you can do so much with it.

However, I hate that, even after a decade using it, I’m still running into basic issues that interrupt my workflow while I go and research the error message to see what’s going on under the hood.

Here’s an example. I was so confident I could delete the local branches I did two at once. And ran into 2 separate error messages. i.e. I did a git branch -d <local_branch1 local_branch2> that had been pushed and merged only to get these messages:

A. warning: deleting branch 'old_branch' that has been merged to 'refs/remotes/origin/old_branch', but not yet merged to HEAD.

Turns out, when you do a merge --squashand delete the remote branch you’ll get this warning. Here’s why:

  1. you created the branch
  2. pushed to remote
  3. merged there and deleted the remote branch
  4. did a pull from origin/master
  5. your local HEAD (master) does not have a record of this merge (even though it was done on the remote) hence the warning



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

Check with:

git log --graph --left-right --cherry-pick --oneline master...<my_branch>



Leave a Reply

Your email address will not be published. Required fields are marked *