# Start new git worktrees in detached HEAD state \(\#53840\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/66ac781e65e253ec143d82fd9512ae0c0b3b4b52)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 66ac781e65e253ec143d82fd9512ae0c0b3b4b52

Requested commit: 66ac781e65e253ec143d82fd9512ae0c0b3b4b52

Commit: 66ac781e65e253ec143d82fd9512ae0c0b3b4b52

Tree: 9b3fc68d13c0cc431185694a2b52d9d2a5100a1d

Author: Richard Feldman

Committer: GitHub

## Message

```
Start new git worktrees in detached HEAD state (#53840)

Create worktrees in detached HEAD state, then attempt to check out the
requested branch. If the checkout fails (e.g. the branch is already in
use by another worktree), log a warning and stay in detached HEAD state
instead of showing an error to the user.

This simplifies the worktree creation flow by:
- Removing the occupied-branch fallback logic that would generate random
branch names
- Always using `CreateWorktreeTarget::Detached` for worktree creation
- Attempting branch checkout as a best-effort post-creation step
- Updating the branch picker UI to reflect the new behavior

Release Notes:

- Threads now start git worktrees in detached HEAD state if branch is in
use or unspecified, instead of generating a random branch name.

---------

Co-authored-by: Eric Holk <eric@zed.dev>
```

## Parents

- [549db9fbb33e09fac82e7441db5857d6f8f670de](https://git.cafe/gitcafe/zed/commit/549db9fbb33e09fac82e7441db5857d6f8f670de?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/66ac781e65e253ec143d82fd9512ae0c0b3b4b52?format=markdown)
