Git will by default deny deleting a local branch (via git branch -d mybranch
), if that branch is not fully merged.
However, if I delete a remote branch via git push origin --delete mybranch
, there is no warning whatsoever if the branch is not fully merged.
This seems rather dangerous: Someone else might have pushed updates to the branch since I last fetched it, so accidentally deleting an unmerged branch seems more likely for a remote branch than in the case of a local branch.
So why does git not warn if I delete a remote unmerged branch? And is there a way to make it warn or deny the deletion?
Note: I realize that ideally I should git pull
the branch before deleting it, and make sure it is fully merged. However, everyone makes mistakes, and I'd like to have a safety net.