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

git branch -D won't delete the branch you're on

From
APAndy Parkins <andyparkins@gmail.com>
Date
Jan 26, 2007, 12:00 UTC
Message-ID
<200701261200.48813.andyparkins@gmail.com>
Hello,

Minor nitpick, that is not dreadfully important, but now that we have the detached HEAD facility, is it reasonable to expect this to work?

 $ git checkout -b somebranch HEAD^
 $ git branch -d somebranch
 error: Cannot delete the branch 'testcvs' which you are currently on.
Especially given that this will work (albeit with a warning):
 $ git checkout HEAD^
 warning: you are not on ANY branch anymore.
 If you meant to create a new branch from the commit, you need -b to
 associate a new branch with the wanted checkout.  Example:
   git checkout -b <new_branch_name> HEAD^
Andy
-- 
Dr Andy Parkins, M Eng (hons), MIEE
andyparkins@gmail.com
Message 1 of 1 in “git branch -D won't delete the branch you're on”
  1. Andy ParkinsJan 26, 2007

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.