The Problem: Stash Breaks on Uncommitted Index State
You're mid-refactor, three files staged, when a production bug lands in Slack. git stash sounds perfect — until you discover it didn't save your staged/unstaged distinction, or worse, it mangles conflicts when you pop.
Here's what actually happens when you stash with mixed index state:
# File: api/middleware.py (staged)
class AuthMiddleware:
def __init__(self, app):
self.app = app
self.rate_limiter = None # Half-finished feature
# File: api/handlers.py (unstaged, working changes)
async def handle_request(req):
# Debugging print you forgot to remove
print(f"Request: {req.path}")
return await process(req)
Run git stash, fix the bug, then git stash pop. Your staged changes are now unstaged. The distinction you carefully maintained — "this is ready, this isn't" — vanished.
I'm not entirely sure why Git's default stash behavior merges staged and unstaged into one blob when git stash --keep-index exists, but in practice, most developers just use git stash and lose that information.
Continue reading the full article on TildAlice
Top comments (0)