git worktree — work on multiple branches simultaneously

# Create a new worktree for a branch
git worktree add ../hotfix-1.x hotfix/1.x

# Now you have two working directories:
#   ./           → your current branch
#   ../hotfix-1.x → hotfix/1.x branch

You need to switch to a hotfix branch urgently but do not want to stash or commit unfinished work on your current branch.

Create a worktree for a new branch

git worktree add -b hotfix/login-null ../hotfix-login main

List all worktrees

git worktree list

Remove a worktree when done

git worktree remove ../hotfix-1.x