258

Is there an option to delete a branch with TortoiseGit?

I found a solution for the commandline. Is there an implementation in TortoiseGit?

Community
  • 1
  • 1
Tarion
  • 16,283
  • 13
  • 71
  • 107

3 Answers3

380

You should read this article: Remote branches with TortoiseGit

According to this blog post:

...remove the local branch by first opening up the Checkout/Switch dialog to get at the Browse refs dialog.

enter image description here

In the Browse refs dialog we can right click on the local branch and choose to delete it.

enter image description here

To delete a remote branch we can do the same thing, but instead of right clicking on our local branch we expand the remotes tree in the left part of the dialog and then locate the remote branch.

enter image description here

Răzvan Flavius Panda
  • 21,730
  • 17
  • 111
  • 169
Sandro Munda
  • 39,921
  • 24
  • 98
  • 123
  • 12
    Btw. please be aware that you cannot delete the branch you are currently on (this will give an error). Also if the branch you want to delete is not visible in the "Browse references" dialog it may have been created recently, do a pull before. And finally there is a direct way to get to "Browse references". See other answer by Razvan Panda. – NoDataDumpNoContribution Sep 09 '14 at 20:00
  • @StijndeWitt There is, see [Răzvan Panda's answer](https://stackoverflow.com/a/13327694/321973) – Tobias Kienzler Feb 16 '17 at 10:47
  • 2
    If you have a lot of old remote branches to clean up, you're probably better off using the command line. I haven't found a way to do this in Tortoise yet. `git remote update origin --prune` will remove any locally saved remote branch refs for branches that no longer exist on `origin`. – Adam Tuttle Apr 05 '17 at 15:01
  • @AdamTuttle It's possible. See way 5 of my answer: https://stackoverflow.com/a/46312594/3247152 – Yue Lin Ho Sep 20 '17 at 06:13
109

You can Shift + Right Click on the cloned repository and choose Browse References from TortoiseGit submenu:

Click on remotes in the left tree view, and then right click the branch you wish to remove and click on Delete remote branch.

You can also get rid of the "shift"+right click: Go to TortoiseGit settings -> "Set extended context menu" and uncheck "Browse References"

NoDataDumpNoContribution
  • 10,591
  • 9
  • 64
  • 104
Răzvan Flavius Panda
  • 21,730
  • 17
  • 111
  • 169
  • 7
    You can also get rid of the "shift"+right click: Go to TortoiseGit settings -> "Set extended context menu" and uncheck "Browse References" – MrTux Mar 29 '15 at 04:24
  • 1
    Also something really helpful with this solution is you can select multiple branches. Came in handy when having to delete 62 branches. Thanks – Low Jan 06 '17 at 12:09
  • @Noki It's possible to delete branches in Browse references dialog. See my answer https://stackoverflow.com/a/46312594/3247152 – Yue Lin Ho Sep 20 '17 at 05:49
  • Did this get removed? I don't see any `Set extended context menu` – Devolus Nov 28 '22 at 09:08
23

Open log dialog first, there are ways to delete branch(es):

  1. Right click on branch
    enter image description here

  2. Right click on commit
    enter image description here

  3. In Browse references dialog
    enter image description here

  4. Delete merged branches
    enter image description here

  5. Delete those remote-tracking branches which its remote branches are not exist on remote
    enter image description here
    [Note] if you want to prune non-exist branches each time you perform fetch, you can do these:
    enter image description here

Yue Lin Ho
  • 2,945
  • 26
  • 36