'Why does Git use a colon (:<branch>) to delete remote branches?
Why does Git use
git push <remote> :<branch>
as in
git push origin :featureA
to delete the branch featureA from the remote server?
I am interested in why the colon was used as the delete flag.
It's so different from git branch -d <localbranch>.
Why don't we do something like
git branch -d --remote origin <branchname>
or is there a deeper meaning behind the colon symbol that I didn't know?
Solution 1:[1]
The colon isn't a "delete flag". Note that git push and git pull both accept zero or more refspecs as their final argument(s). Now read about refspecs. A colon separates source from destination in a refspec. The command git push origin :foo has an empty source and essentially says "push nothing to branch foo of origin", or, in other words, "make branch foo on origin not exist".
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Andris |
