Skip to main content

2 posts tagged with "worktree"

worktree tag description

View All Tags

Use `git worktree` for Hotfixes: A Better Alternative to Stash

· 6 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

We have all been there: you are deep in the zone, half-way through building a complex new feature, and your terminal is full of uncommitted changes. Suddenly, you get a message from your team: "Critical bug in production! We need a hotfix right now!"

The traditional response is to use git stash, switch to main, fix the bug, and then try to un-stash your messy feature branch later. But if you have complex dependencies (like node_modules or .venv) or untracked files, stashing can lead to absolute chaos.

This is where git worktree comes in. It is the professional's secret weapon for parallel development.

How to Fix 'fatal: cannot delete branch used by worktree' in Git

· 5 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

Git is usually pretty good at protecting us from our own mistakes. When you try to delete a branch and get hit with the fatal: cannot delete branch 'xyz' used by worktree at '/path/to/folder' error, Git is essentially acting as a safeguard.

It is telling you: "I can't delete this branch because it is currently checked out and actively being used in another folder on your computer!"

Here is exactly why this happens and how to resolve it safely.