Why Git Uses (:) to Delete Remote Branch
It would appear that the colon in git push origin :<branch-to-delete>
is used exclusively to delete branches. But such is not the case.
The format for the refspec is*:
<source>:<destination>
This tells Git to push the source
branch to the destination
branch in remote. So if the source
is blank, we get a leading colon. This has the effect of deleting the destination
branch. Its like saying “push null pointer to destination”.
*You can learn more about the refspec in its entirety in this Stack Overflow
Written on November 10, 2016 by shahriyarnasir