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
Jacob Keller <jacob.keller@gmail.com>
Date
Jul 7, 2016, 23:39 UTC
Message-ID
<CA+P7+xoM=-=sokA_+WDuY7KYUwSa=Qu8Y9U1aPHOgSH3n-VZnA@mail.gmail.com>
In-Reply-To
<20160707184408.GA1916@gmail.com>
On Thu, Jul 7, 2016 at 11:44 AM, Erik Johnson <palehose@gmail.com> wrote:
Show 14 quoted lines
> % git branch -D archive-extracted-xz
> error: Cannot delete branch 'archive-extracted-xz' checked out at
> '/home/erik/git/salt/archive-extracted-xz'
> % test -d /home/erik/git/salt/archive-extracted-xz || echo "directory
> doesn't exist"
> directory doesn't exist
> % git --version
> git version 2.9.0
>
> I know that I can just get rid of this error by pruning the worktrees,
> but this still seems like incorrect behavior on the part of git branch.
> It shouldn't be telling me that the branch is checked out in a directory
> that does not exist, that is just factually incorrect.
>

Until the worktree status is updated git branch probably isn't checking itself. It might be worth triggering a worktree prune when doing branch work. Note that some worktrees may be on removable media or similar, and thus even if the directory doesn't exist right now, that does not mean it's no longer checked out. There is already support for setting a worktree as "persistent", but this means git branch definitely shouldn't just do its own check for non existent directory.

Thanks, Jake

Show 7 quoted lines
> --
>
> -Erik
>
> "For me, it is far better to grasp the universe as it really is than to
> persist in delusion, however satisfying and reassuring."  --Carl Sagan
>
Previous: Erik JohnsonNext: Erik Johnson
Message 2 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.