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

Re: git branch doesn't allow me to forcibly delete branch which was checked out in a now-deleted worktree dir

From
Duy Nguyen <pclouds@gmail.com>
Date
Jul 9, 2016, 05:33 UTC
Message-ID
<CACsJy8BWAirnni+-ZzShMrKO0Pjs8xiUw1gXSJAR2ZT9kJFtuQ@mail.gmail.com>
In-Reply-To
<20160707184408.GA1916@gmail.com>
On Thu, Jul 7, 2016 at 8:44 PM, Erik Johnson <palehose@gmail.com> wrote:
> % git branch -D archive-extracted-xz
> error: Cannot delete branch 'archive-extracted-xz' checked out at
> '/home/erik/git/salt/archive-extracted-xz'

This is from commit f292244 (branch -d: refuse deleting a branch which is currently checked out - 2016-03-29) which is about -d not -D, so it's probably an oversight. I think -D, as a forced form, should allow deleting branches on other worktrees, we could simply detach the worktree first.

It's worth noting that before that commit, -D refuses to delete branch on current worktree as well and f292244 simply applies the same behavior on other worktrees. If we change the -D behavior about deleting branches on other worktrees, we may need to consider to keep the behavior on current branch, or treat it equally as any other worktrees.

-- 
Duy
Previous: Erik Johnson
Message 8 of 8 in “git branch doesn't allow me to forcibly delete branch which was checked out in a now-deleted worktree dir”
  1. Erik JohnsonJul 7, 2016
  2. Jacob KellerJul 7, 2016
  3. Erik JohnsonJul 8, 2016
  4. Jacob KellerJul 9, 2016
  5. Erik JohnsonJul 9, 2016
  6. Jacob KellerJul 9, 2016
  7. Erik JohnsonJul 9, 2016
  8. Duy NguyenJul 9, 2016

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.