Check out the same branch in two worktrees

basics

// what it does

--force overrides Git's one-branch-per-worktree rule and checks out a branch that's already checked out elsewhere. The rule exists because a commit made in either worktree leaves the other with a stale HEAD whose files no longer match the branch tip.

// shell

$ git worktree add --force ../myapp-copy feature-x
$ git worktree add -d ../myapp-copy feature-x

// gotcha

This is almost never what you actually want. If you just need the files at that branch's state, use a detached worktree instead: git worktree add -d ../copy feature-x gives you the content with no shared-branch hazard.

// resources