Create a worktree with a new branch
basics
// what it does
-b creates feature-auth starting at main (or at HEAD if you omit the start point) and checks it out into the new directory in one step — the everyday way to open a parallel line of work. -B does the same but resets the branch to the start point if it already exists.
// shell
$ git worktree add -b feature-auth ../myapp-auth main$ git worktree add -B feature-auth ../myapp-auth main// gotcha
-B force-moves an existing branch to the start point, abandoning whatever it pointed to before — commits reachable only from that branch survive only in the reflog. Reach for it in scripts that recycle branch names, not in day-to-day use.