git/list[1] front-page[2] threads[3] people[4] search[5] about
 

How to delete all merged branches?

From
Stefan Beller <stefanbeller@googlemail.com>
Date
Feb 16, 2014, 17:37 UTC
Message-ID
<5300F748.2060805@googlemail.com>
Hi,
so I tend to accumulate lots of branches as I'd do one 
branch per feature. When cleaning up, I'd like to 
delete all branches, which have been merged.
I could use 
	$ git branch -d (which was merged already?) ^C
	$ git branch --merged # let's find out
	...
	$ # Now run git branch -d with each of the branches.
This kind of question has already been discussed, 
http://stackoverflow.com/questions/6127328/how-can-i-delete-all-git-branches-which-are-already-merged
suggests:
	git branch --merged | grep -v "\*" | xargs -n 1 git branch -d
Now it seems as if this operation would be needed by quite a few people
actually. Maybe it's time to integrate into git? I'd be interested, which
way would be the most git-like way to do it.
I could think of:
	$ git branch -d --merged # no need to specifiy a branch iff --merged is given with -d
	$ git branch --delete-merged 	# comes as an new extra option, doesn't clutter other commands
	$ git branch -d keyword-for-all-merged-branches
Before starting such a feature, I'd like to hear input of others.

Thanks, Stefan

Next: Jamie Couture
Message 1 of 2 in “How to delete all merged branches?”
  1. Stefan BellerFeb 16, 2014
  2. Jamie CoutureFeb 16, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.