git worktree
Check out multiple branches into different directories simultaneously without switching or stashing
Syntax
git worktree <subcommand> [<options>]
Parameters
| Parameters | Description | Examples | Level |
|---|---|---|---|
add <path> [<branch>] |
New | |
Common |
list |
|
Common | |
remove <worktree> |
|
Common | |
prune |
|
Common | |
add -b <new-branch> <path> |
NewNew | |
Common |
Examples
hotfix
git worktree add ../hotfix-branch hotfix/login
NewNew
git worktree add -b feature/new ../feature-work
git worktree list
/home/user/project abc1234 [main]
/home/user/hotfix-branch def5678 [hotfix/login]
git worktree remove ../hotfix-branch
git worktree prune
Tips
- ( bug New)
- git stash + checkout,
- .git,
- remove,