If your current Git working directory is unfinished or in disarray, you can leave it alone and handle an urgent fix in a second directory with git worktree. Git’s manual uses this exact interruption scenario: create a temporary linked worktree, make and commit the fix there, then remove the temporary directory and return to the original work.
What a linked worktree gives you
A Git repository can have its main working tree plus one or more linked working trees, letting you check out different branches at the same time. A linked worktree is associated with the same repository; it is not a separate clone. Repository data is shared, while each worktree has its own files for its current HEAD and index. Use git worktree list to see the registered worktrees and their checked-out revisions or branches.
As an Amazon Associate I earn from qualifying purchases.
This is useful when an urgent task needs a separate working directory and you do not want to risk disturbing the state of the directory where you are already working. Git documents this as one possible response to an interruption, not as a universal replacement for stashing changes.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Create a temporary worktree for the urgent fix
From your current repository, adapt the branch name, path, and starting branch to suit the task. In this example, master, emergency-fix, and ../temp are illustrative values:
#1 Best Overall
git worktree add -b emergency-fix ../temp master
cd ../temp
# make the urgent change
git commit -a -m 'emergency fix for boss'
cd -
git worktree remove ../temp
git worktree add -b emergency-fix ../temp mastercreates a new branch namedemergency-fix, based onmaster, and checks it out in../temp.- Change into the new directory, make the urgent change, and commit it. The example uses
git commit -a, which stages modifications and deletions to tracked files; it does not stage new, untracked files. Stage those explicitly before committing if the fix adds files. - Return to the original directory and remove the temporary worktree with
git worktree remove ../temp.
If you want to create a branch based on the current HEAD and the final path component is a suitable branch name, git worktree add ../hotfix creates the directory and uses hotfix as the branch name, provided that branch does not already exist.
Choose between a worktree and stash
git stash stores changes from a dirty working directory so they can be inspected or applied later. A linked worktree instead gives the separate task another path to work in. The right choice depends on what you need to preserve and how you want to work, rather than on a documented speed or safety advantage.
Rank #2
| Question | Stash | Linked worktree |
|---|---|---|
| What happens to the current directory? | Changes are stored away from the dirty working directory for later restoration. | The existing directory stays in place while the separate task uses another directory. |
| Where do you do the urgent task? | In the working directory after stashing and switching context as needed. | In a second path associated with the repository. |
| When is it a natural fit? | When you want to store current changes and later list, inspect, or apply them. | When the current directory is in disarray and you do not want to risk disturbing it. |
Git’s manuals describe command behavior, not measured comparisons of speed, safety, or productivity. For details on stash operations, see the Git stash manual; for worktree commands and constraints, see the Git worktree manual.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Check and clean up worktrees safely
- Run
git worktree listto inspect registered worktrees before adding or removing one. - Ordinarily,
git worktree remove <path>removes a clean worktree only. Git refuses removal if tracked files are modified or untracked files remain. - Force removal is available for an unclean worktree, but it bypasses that safeguard. Inspect the files and confirm you are willing to discard them before using force.
- A branch checked out in another worktree ordinarily cannot be checked out again in a new worktree; Git refuses the duplicate checkout unless forced.
If a worktree’s location or metadata gets out of sync
If you move a worktree manually and its association with the repository breaks, git worktree repair can reconnect the metadata. If you manually delete a worktree directory and stale metadata remains, git worktree prune can remove stale entries. Prefer Git’s worktree commands for normal cleanup, and use repair or prune for these recovery cases.
Quick Recap
Best Value
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




