About This Article
This article is created using an automated generation workflow utilizing generative AI. It covers how to use git worktree to simultaneously check out a hotfix branch in a separate folder while maintaining main in the same Git repository.Verification Status: 📘 Verified with official Git documentation – Unverified on physical hardware
Information verification date: October 4, 2026.
When you are verifying operation on main but also want to open an urgent fix branch, instead of stashing and switching checkouts every time, you can use git worktree to maintain multiple working trees in the same repository.
Checking the Current Working Tree
git status git worktree list
First, check for uncommitted changes and existing worktrees.
Creating a Hotfix in a Separate Folder
This is an example of creating a myrepo-hotfix in the parent folder of the repository and checking out a new hotfix branch.
git worktree add ../myrepo-hotfix -b hotfix
Upon success, the original folder remains on the original branch, while hotfixes can be edited in the separate folder.
project/ mainの作業ツリー myrepo-hotfix/ hotfixの作業ツリー
The official Git documentation states that a repository can have a main worktree in addition to zero or more linked worktrees.
Viewing the List
git worktree list
You can verify which branch is assigned to which path.
Delete when finished
After committing and pushing the necessary changes on the hotfix side, if the working tree is clean, you can delete it from the original repository or elsewhere.
git worktree remove ../myrepo-hotfix
Normally, worktrees with untracked or uncommitted changes cannot be safely deleted as-is. Instead of suddenly using --force, first check git status.
Difference from checkout switching
| Method | Keeping main open | Separate directory | Use case |
|---|---|---|---|
| git switch | × | × | Working one by one |
| git worktree | ○ | ○ | Parallel modification, comparison, and building |
The key advantage is that instead of cloning a large repository entirely all over again, you can share Git management information and create an additional working location.
Precautions
There are restrictions when attempting to check out the same branch into multiple worktrees normally. Please use git worktree list to check which worktree is using which branch.

