Git Academy

Advanced · 4 min read

Worktrees: several branches checked out at once

An urgent hotfix while you're in the middle of a feature? No stash, no mess.

Create a second working folder

Same repository, another folder, another branch. Your current work stays untouched.

Safe
$ git worktree add ../my-project-hotfix -b hotfix/login main

List and remove

A branch can only be checked out in one worktree at a time.

Safe
$ git worktree list
$ git worktree remove ../my-project-hotfix