Reputation: 8105
Using Intellij IDE (I have version 2017.3.5) is there a way to delete multiple local git branches at once
Upvotes: 74
Views: 35798
Reputation: 3409
You can delete multiple branches in IntelliJ IDEA directly.
Go to tab Git / Log (bottom of IDE) (or via IDE top menu Git / Show Git Log). Here open the Tree View on the left side and right mouse click. Check this picture:
Note: You will not see this menu item on current branch so select another or multiple of them.
Source: https://youtrack.jetbrains.com/issue/IDEA-131571
Upvotes: 148
Reputation: 1
It's easy to delete multiple branch on Git Extensions. http://gitextensions.github.io/
Upvotes: 0
Reputation: 4476
// Update Feb 2021:
As mojmir.novak pointed out here: https://stackoverflow.com/a/65954247/1546042 you can do this now in IntelliJ. To remove only merged branches, see answer below:
// Older update:
To clean-up (old) feature branches that have been merged to master you can use the terminal to clean it up.
To delete all local branches that are already merged into the currently checked out branch:
git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d
See https://stackoverflow.com/a/6127884/1546042 for more details.
Cleaning up using run config"
In order to clean up multiple branches at once, using intelliJ. You need to install the Bash Support plugin and use it to create a run config that executes a script with the above command.
~/scripts/clean-branches.sh
)Bash
run config.Upvotes: 27
Reputation: 1485
Have been through the pain of cleaning up the unused branches, and found this plugin.
https://plugins.jetbrains.com/plugin/10059-git-branch-cleaner/
But I was not able to see the VCS > Git
menu on my Mac - IntelliJ
But was successful in finding a similar option under git > context-menu - Delete old branches...
I am not sure if there is a default option or this is because of the above-mentioned plugin.
Sharing to help others who don't have VCS > Git menu like in my case
Upvotes: 2
Reputation: 4209
There is a Plugin available for this:
https://plugins.jetbrains.com/plugin/10059-git-branch-cleaner/
To use it once it's installed, in the main menu go to:
VCS > Git > Delete Old Branches
Upvotes: 17