Git Worktree: How to Work on Multiple Branches at Once

You鈥檙e three files into a feature branch, nothing committed, when a teammate pings you about a null-pointer crash in production. The usual move is git stash, check out main, fix it, push, then git stash pop and hope nothing in your half-finished feature depended on the files you switched away from. git worktree skips the shuffle. It checks out the hotfix branch into a second folder, next to your feature branch, with both backed by the same repository. ...

October 24, 2026 路 5 min 路 974 words 路 SpaghettiCoder

Git Reset vs Revert vs Restore: How to Undo Changes

Run git reset --hard on a commit your team already pulled and you鈥檝e just made your history disagree with theirs. Run git revert on a typo you haven鈥檛 pushed and you鈥檝e added a pointless commit to the log. Git has four undo commands, restore, reset, commit --amend and revert, and they are not interchangeable. Pick the wrong one and it either does nothing or does far more than you wanted. ...

October 3, 2026 路 7 min 路 1286 words 路 SpaghettiCoder

How to Use Git Bisect to Find a Broken Commit

The test suite has been green for three weeks. Today npm test fails on an assertion that has nothing to do with what you just changed, and git log v1.4.0..HEAD shows 340 commits from four people since the last release anyone is sure worked. Reading every diff costs you a day. Checking out commits at random is faster and still not a plan. git bisect turns that into a binary search. You give it one commit you know is good and one you know is bad; it checks out the commit halfway between them and waits while you test that single commit and report back. Each answer halves the range. 340 commits resolve in at most 9 tests, since 2^9 = 512. ...

September 22, 2026 路 6 min 路 1104 words 路 SpaghettiCoder

Git Rebase vs Merge: When to Use Each

You pull the latest main and Git stops with CONFLICT (content): Merge conflict in checkout.js. You resolve it, and the log now shows a commit called Merge branch 'main' into feature/checkout sitting on top of the three commits you actually wrote. Four commits, one real change. A teammate reading that history next month can鈥檛 tell which is which. git merge and git rebase both answer the same question: how do I bring my branch up to date with changes made elsewhere. They leave very different traces behind, and picking the wrong one on a shared branch causes real damage. ...

September 13, 2026 路 8 min 路 1537 words 路 SpaghettiCoder