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

Re: Git branch deletion not based on HEAD branch anymore

From
Javier Domingo Cansino <javierdo1@gmail.com>
Date
Apr 7, 2017, 11:17 UTC
Message-ID
<CALZVapk1nhBv04QQSV9jOpg-KQxVE8wKgV9dgwm0m+J3fxsD3g@mail.gmail.com>
In-Reply-To
<20170407063808.frjjclz7ksqgmtyt@sigill.intra.peff.net>
Show 6 quoted lines
> There's "branch --merged" already. And in recent versions of git, the
> scriptable for-each-ref knows it, too. So you could do something like:
>
>   git for-each-ref --format='delete %(refname)' --merged HEAD refs/heads/ |
>   grep -v 'any-branches-you-want-saved' |
>   git update-ref --stdin

Yeah I wanted to avoid anything else that git branch -d, as it doesn't delete the currently checked out. I am not really familiar with plumbing commands.

> The "--merged" option to git-branch is only used for listing. In theory
> we could use it for selection in other operations, like "git branch -d
> --merged". But I'm not sure how you'd tell it _not_ to delete the branch
> that matches HEAD.

Last time I checked git branch doesn't delete the currently checked out branch, does it?

Adding the --merged to `git branch -d` would be awesome
Javier
Previous: Jeff King
Message 3 of 3 in “Git branch deletion not based on HEAD branch anymore”
  1. Javier Domingo CansinoApr 6, 2017
  2. Jeff KingApr 7, 2017
  3. Javier Domingo CansinoApr 7, 2017

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.