git worktree
Manages multiple working trees attached to the same repository, allowing you to check out multiple branches simultaneously.
Syntax
git worktree <subcommand>
Options
- add <path> [<branch>]: Creates a new working tree at the given path
- list: Lists all linked working trees
- remove <worktree>: Removes a working tree
- prune: Cleans up stale working tree information
- lock / unlock: Prevents or allows automatic pruning of a worktree
Example
git worktree add ../hotfix hotfix/urgent git worktree list git worktree remove ../hotfix
Tip
Use worktrees to work on a hotfix without stashing your current work.