-3

when we fire command

git branch -D <branch_name>
git branch -d <branch_name>

what is the difference and how the execution of each of the command occurs?

Samrat
  • 101
  • 1
  • 8
  • 2
    Possible duplicate of [How do I delete a Git branch both locally and remotely?](https://stackoverflow.com/questions/2003505/how-do-i-delete-a-git-branch-both-locally-and-remotely) – Johan Sep 25 '18 at 10:02
  • 2
    Have you looked at the documentation for `git branch`? It's quite clear. – ChrisGPT was on strike Sep 25 '18 at 15:56

2 Answers2

2

The -d version first checks if the branch has commits which are unmerged into its upstream counterpart. If there are some, the delete is denied.

The -D version forces the deletion.

Check the doc if needed.

Romain Valeri
  • 19,645
  • 3
  • 36
  • 61
1

This is already answered in another thread. Basically this is what's been said

To delete the local branch use one of the following:

$ git branch -d branch_name
$ git branch -D branch_name

Note: The -d option is an alias for --delete, which only deletes the branch if it has already been fully merged in its upstream branch. You could also use -D, which is an alias for --delete --force, which deletes the branch "irrespective of its merged status." [Source: man git-branch]

Johan
  • 3,577
  • 1
  • 14
  • 28