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

Re: deleting a branch

From
Daniel Barkalow <barkalow@iabervon.org>
Date
Sep 13, 2005, 16:23 UTC
Message-ID
<Pine.LNX.4.63.0509131217490.23242@iabervon.org>
In-Reply-To
<7v4q8p3qd8.fsf@assigned-by-dhcp.cox.net>
On Tue, 13 Sep 2005, Junio C Hamano wrote:
Show 12 quoted lines
> "rm -f .git/refs/heads/no-longer-needed".  Make sure your
> working tree is not on that branch (i.e. .git/HEAD should not be
> pointing at it).
> 
> I have not introduced "git branch -d no-longer-needed" because
> I think that should do a bit more than "rm -f".  For example:
> 
>  - making sure you are not on that branch (obvious),
> 
>  - check if all changes on that branch are included in the
>    master branch or some other branch (easy if we hardcode "master";
>    checking all other branches might be nicer but expensive).

You could check HEAD. I think the most common cases would either be that you just created a branch from HEAD and changed your mind, or that you've just merged the branch into something. Other that that, I think the common case is that you've made patches, sent them off, and they were accepted. In the first two, you're probably on the branch that includes or matches the one you're deleting; on the third, we want user confirmation, since it's external to the system.

	-Daniel
*This .sig left intentionally blank*
Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 6 in “deleting a branch”
  1. Chuck LeverSep 13, 2005
  2. Junio C HamanoSep 13, 2005
  3. Daniel BarkalowSep 13, 2005
  4. git-branch -d <branch>: delete unused branch.Junio C Hamano, Sep 14, 2005
  5. Chuck LeverSep 14, 2005
  6. Junio C HamanoSep 14, 2005

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.