Can some body please help me to understand what is the difference between following two git commands?
$ git branch -d testing
and
$ git branch -D testing
When should we use -D?
Can some body please help me to understand what is the difference between following two git commands?
$ git branch -d testing
and
$ git branch -D testing
When should we use -D?
git branch -d is for deleting branches that are fully merged in its upstream branch or to HEAD if you don't have a upstream for your branch. If the branch is not fully merged it will not perform the deletion.
git branch -D deletes the branch even if it's not merged.
In complement to the other answer: think of -D as -d --force. -d is the safe option, you probably want to teach your fingers to use this one. When -d refuses to delete the branch, make sure you know what you're doing, and then use -D.
Actually, -D sounds so much like -d --force that you can indeed use -d --force since Git 2.3.