git worktree
A command that checks out another branch into a separate folder that shares the same repository, so you can work on two branches at once.
In more detail
git worktree add ../hotfix fix-bug creates a second working tree for fix-bug without disturbing uncommitted work in the first, and git worktree list shows them all. Each branch can be checked out in only one worktree at a time.
Example
git worktree add ../hotfix fix-bugRelated terms
- working tree — The files of a Git repository as they currently exist on disk, which you edit before staging and committing.
- git switch — The command that moves you to another branch, updating HEAD and the working tree to match; -c creates the branch first.
- hotfix — An urgent, unplanned change deployed to repair a problem in production.
Taught in
- Undoing: restore, reset, revert And stash — Advanced Git Internals & Distributed Workflows
- Investigating History: blame, bisect And worktree — Advanced Git Internals & Distributed Workflows