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

Re: git branch -D doesn't work with deleted worktree

From
Jacob Keller <jacob.keller@gmail.com>
Date
Jan 9, 2017, 03:44 UTC
Message-ID
<CA+P7+xofFufcUMBJFqEcP=C5r80HCr1-j4210gOm7t=aLYw2zw@mail.gmail.com>
In-Reply-To
<CACsJy8C6QWeHSwhsYyJnupkue=aoCG+3Tecytb_0p+gB-CuVKg@mail.gmail.com>
On Fri, Jan 6, 2017 at 2:05 AM, Duy Nguyen <pclouds@gmail.com> wrote:
Show 26 quoted lines
> On Thu, Jan 5, 2017 at 9:02 PM, Stefan Beller <sbeller@google.com> wrote:
>> On Thu, Jan 5, 2017 at 2:06 AM, Roland Illig <rillig@novomind.com> wrote:
>>> Git 2.11.0 gives a wrong error message after the following commands:
>>>
>>> $ git init
>>> $ echo hello >file
>>> $ git add file
>>> $ git commit -m "message"
>>> $ git worktree add ../worktree
>>> $ rm -rf ../worktree
>>> $ git br -D worktree
>>> error: Cannot delete branch 'worktree' checked out at '../worktree'
>>>
>>> Since ../worktree has been deleted, there cannot be anything checked out at that location.
>>>
>>> In my opinion, deleting the branch should just work. Especially since I used the -D option and the "git worktree" documentation says "When you are done with a linked working tree you can simply delete it."
>
> Since -D means "I know what I'm doing, get out of my way", maybe we
> should continue if any worktree has the branch checked out by
> detaching it?
>
> (Yes I'm carefully tip toeing around the deleted worktree issue since
> "git worktree remove" is coming. After that point, running "worktree
> prune" before "branch -D" does not sound so bad)
> --
> Duy

Why not just update the documentation to be "when you are done with a work tree you can delete it and then run git worktree prune"?

Thanks, Jake

Previous: Duy NguyenNext: Duy Nguyen
Message 4 of 7 in “git branch -D doesn't work with deleted worktree”
  1. Roland IlligJan 5, 2017
  2. Stefan BellerJan 5, 2017
  3. Duy NguyenJan 6, 2017
  4. Jacob KellerJan 9, 2017
  5. Duy NguyenJan 9, 2017
  6. Jacob KellerJan 10, 2017
  7. Duy NguyenJan 10, 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.