Git Stash, Worktree, and Clean Cheat Sheet/Create worktree and new branch together

Add a worktree and create a new branch from current HEAD.

Section: Worktree Workflows

Create worktree and new branch together

bash
bash
git worktree add -b hotfix ../hotfix
Explanation

A fast way to spin up a new isolated working directory for urgent work.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Worktree Workflows
List worktrees
Show all linked working trees for the repository.
OpenIn sheetbashsame section
Create a detached worktree at a commit
Check out a specific commit in a new working tree.
OpenIn sheetbashsame section
Lock a worktree
Prevent a worktree from being pruned or accidentally removed.
OpenIn sheetbashsame section
Prune stale worktree administrative entries
Clean up references to missing worktree directories.
OpenIn sheetbashsame section
Remove a worktree
Delete a linked worktree entry and directory.
OpenIn sheetbashsame section
Create a branch from a stash
Check out a new branch and apply a stash there.
OpenIn sheetbash2 tag match