Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ - GIT delete local orphan branch in GUI

I use IntelliJ (2016.1.3) and GIT integration plugin (8.1). During my use of IntelliJ I checked out multiple branches. Now those branches are deleted from GIT (after each pull request we delete them).

From now on every branch I checked out once is present in my GIT view from Intellij (by VCS > Git > Branches...), see under :

enter image description here

There is a way to delete them : do it ... one by one ! But if there are a lot of branches (let say a hundred ...), it certainly getting tedious...

The question is : Do you know if there is a simple way to delete all the orphan local branches from this view in IntelliJ ?

Thanks :)

EDIT : I have found a way to delete them but in another tool : "Git Gui". When you delete it from there, it's deleted in IntelliJ too. And you can delete multiple branches at one time.

like image 557
Guillaume M Avatar asked Jul 21 '16 15:07

Guillaume M


People also ask

How do I delete local branches in Intellij?

In the Branches popup or from the Branches pane of the Git tool window, right-click the branch you want to delete and choose Delete.

How do I delete an orphan branch?

Use git prune to remove orphaned/unused branches If you see any branches in there that you don't want, you can use the command git branch -d <branch name> . If you want to delete the branch called badbranch, use the -D switch to force the deletion if it doesn't work: git branch -d badbranch .


2 Answers

The Intellij-Plugin GitToolBox offers an option called "Git branches cleanup" which does just what you appear to need.

Once installed, go to Git -> GitToolBox -> Git branches cleanup and select those branches you wish to delete.

like image 111
Morlin Avatar answered Sep 21 '22 13:09

Morlin


To make deletion of a lot of branches a little less painful you may go to the git tool window (Hotkey Alt + 9). In the branches panel it is possible to select multiple branches and delete them.

So you do not have to delete them one by one. But be aware to not delete branches that are still of interest as you are not able to see the connection to remote branches or if this is pruned in this view.

like image 36
Sandro L Avatar answered Sep 21 '22 13:09

Sandro L