Skip to content
Discussion options

You must be logged in to vote

Good question, and worth a docs note. Behavior comes from internal/git/git.go::resolveWorktreeBranch plus the underlying git worktree add semantics. For your bare-repo case:

  1. If the branch name you give already exists locally in the bare repo: it's reused. The worktree checks out that branch's existing tip.
  2. If it doesn't exist locally but exists on the default remote (e.g. origin/feat/foo): tracked from the remote. Worktree starts at the remote tip.
  3. If it doesn't exist anywhere: a new branch is created — and this is the bit you're asking about — branched from HEAD in the bare repo. In a bare repo, HEAD is whatever ref <repo>.bare/HEAD points at. Usually refs/heads/main (or master) since t…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Clindbergh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants