How to Fix a Hotfix in a Git Worktree Without Stashing
Production just caught fire and your working directory is a mess of half-finished edits. Stashing that work is how it ends up dying in a merge conflict three days later. Git already has the fix built in, and it does not need a plugin.
That fix is git worktree. It hands you a second checkout of the same project in a sibling folder, so you can patch the emergency there while everything you were doing stays exactly where it was. Your work in progress is untouched, and your dev server cache stays intact.
What You Need
- Git installed on your machine.
Tutorial
- Run
git worktree add ../hotfix main. This creates an isolated checkout of the project in a sibling folder, and it does not disturb the directory you are already working in.
- Fix the bug in that new folder, then commit it. Work in the
hotfixcheckout like any other, and your uncommitted changes plus your running dev server keep going as before.
- Run
git worktree remove ../hotfix. The temporary checkout is cleaned up once the fix is in, and your original working directory is still the one you left.
Wrapping Up
You now have a way to handle a production emergency without shoving half-baked work into a stash you may never sort out. The next time something breaks, add a worktree, fix it there, and remove the folder when you are done. Try it on a throwaway branch first so the commands feel familiar before the real fire starts.
Does this still work?
Nobody's checked yet
Sign in to tell everyone how it went.
Continue with GoogleBe the first — one tap saves the next person an hour.
It takes 3 reports in 30 days to set the status.
More shares you might like
Tools226 AI Motion Graphics Examples With Copy-Paste PromptsAlex Ruiez · 16h · 21 views
ToolsHow to Make Pinterest Pins for Shopee Affiliate With PhotoRoomAlex Ruiez · 1d · 21 views
MobileHow to Send TikTok Stickers to WhatsAppAlex Ruiez · 1d · 27 views
ToolsHow to Get 2 XXI Tickets for 23rb With GoPayAlex Ruiez · 2d · 28 views
AIGitHub Repo Collects 517+ Claude Opus 5.5 Video PromptsAlex Ruiez · 2d · 32 views
NewsOpen-slide 2.0 Adds a Visual Editor and Editable PPTX ExportAlex Ruiez · 3d · 32 views
Comments
Join the conversation — sign in to comment.
No comments yet — start the conversation!