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
Senior Software Engineer & System Architect specializing in Python, Web Systems, Cloud Infrastructure & Automation

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

· 6 min read
Serhii Hrekov
Senior Software Engineer & System Architect specializing in Python, Web Systems, Cloud Infrastructure & Automation

Git provides safeguards to protect your active code branches from accidental deletion. When you try to delete a branch and receive the error: fatal: cannot delete branch 'xyz' used by worktree at '/path/to/folder', Git is warning you that the branch is currently checked out and actively linked to another working directory on your machine.

Here is why this error occurs, how to resolve it using three different methods, and how to use the listing commands to manage your workspace.