3

How to delete a Git branch with TortoiseGit has been partially answered here. However it doesn't cover the --force option. How can I use TortoiseGit's delete branch feature without the --force option?

Fabien Bouleau
  • 464
  • 3
  • 11

2 Answers2

2

When you use the "Browse References Dialog" (Context menu: TortoiseGit → Browse Reference..., you might need to hold Shift while opening the context menu) for deleting local branches, TortoiseGit checks whether a specific branch is already merged into HEAD and presents a different confirmation dialog.

cf. TortoiseGit manual: https://tortoisegit.org/docs/tortoisegit/tgit-dug-browse-ref.html

Starting with TortoiseGit 2.5.6 before deletion of a local branch it is checked whether it was merged to HEAD and the result is displayed, so that you can decide whether to delete the branch or not.

MrTux
  • 32,350
  • 30
  • 109
  • 146
1

TortoiseGit uses git.exe branch -D to delete branch if libgit2 is not employed to delete refs. And, there is no use case for -d option. See:

enter image description here

(From TortoiseGit 2.5.2 source code)

However, TortoiseGit usually asks user if they want to delete the branch. See:

enter image description here

Useful information: (from comment by @Fabien Bouleau)

Git with "-d" checks that the branch has been merged before deleting.
TortoiseGit shows an agnostic prompt, a confirmation to prevent a click by mistake.
But it does not preserve your work.

(If you deleted an unmerged branch, you can get it back by using Reflog dialog. Actually, get those commits back. :P )

Yes. TortoiseGit should do something for deleting unmerged branch.

MrTux
  • 32,350
  • 30
  • 109
  • 146
Yue Lin Ho
  • 2,945
  • 26
  • 36
  • 1
    Git with "-d" checks that the branch has been merged before deleting. TortoiseGit shows an agnostic prompt, a confirmation to prevent a click by mistake. But it does not preserve your work. Anyway, thanks for the answer! I will submit a request to the TortoiseGit wish list! – Fabien Bouleau Sep 20 '17 at 04:05
  • For deleting merged branches, I also provided an answer at https://stackoverflow.com/a/46312594/3247152 – Yue Lin Ho Sep 20 '17 at 05:20
  • I am adding your comment into my answer. Thank you. – Yue Lin Ho Sep 20 '17 at 05:27