what do I have?
$ git worktree list
This guide assumes branches, commits, and checkouts already feel familiar. If they don’t, start with git — the simple guide (opens in a new tab).
the problem
You’re fixing main, but your half-finished feature needs to stay exactly where it is. A worktree gives another branch its own folder while sharing the same repository history.
$ git worktree add \
../my-app-login \
feature/login
Need a new branch instead?
Add -b before the new branch name:
git worktree add ../my-app-login -b feature/login
tidying up
Two commands to help you clean up after yourself.
$ git worktree list
$ git worktree remove \
../my-app-login
Remove the folder when its work is committed. The branch stays safe in Git; only the extra working folder goes away.
add. work. list. remove. that’s the whole guide.