Quantcast
Channel: Active questions tagged ubuntu - Stack Overflow
Viewing all articles
Browse latest Browse all 6505

Delete all local git branches

$
0
0

I follow a development process where I create a new local branch for every new feature or story card. When finished I merge the branch into master and then push.

What tends to happen over time due to a combination of laziness or forgetfulness, is that I end up with a large list of local branches, some of which (such as spikes) may not have been merged.

I know how to list all my local branches and I know how to remove a single branch but I was wondering if there was a git command that allows me to delete all my local branches?

Below is the output of the git branch --merged command.

user@machine:~/projects/application[master]$ git branch --merged  STORY-123-Short-Description  STORY-456-Another-Description  STORY-789-Blah-Blah* master

All attempts to delete branches listed with grep -v \* (as per the answers below) result in errors:

error: branch 'STORY-123-Short-Description' not found.error: branch 'STORY-456-Another-Description' not found.error: branch 'STORY-789-Blah-Blah' not found.

I'm using:

git 1.7.4.1  ubuntu 10.04  GNU bash, version 4.1.5(1)-release  GNU grep 2.5.4  

Viewing all articles
Browse latest Browse all 6505


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>