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:
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:
- you created the branch
- pushed to remote
- merged there and deleted the remote branch
- did a pull from origin/master
- 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>'
git log --graph --left-right --cherry-pick --oneline master...<my_branch>