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