skipnothing/Git

Stash & Worktrees

You're mid-edit in app.py when a teammate pings: their fix needs the working tree clean right now. You don't want a half-baked commit, and you don't want to lose the last hour of work.

  • ▸cat .git/refs/stash prints one hash: the work you set aside is a commit with two parents.
  • ▸A git stash pop that succeeds drops the entry from the stash list; git stash apply keeps it there.
  • ▸A second working tree copies zero objects: the store is shared, only HEAD and index are private.
BUILDS ON
01

Stash, or a second workspace

The edits to app.py and config.json are half-finished, and the teammate's fix cannot wait. Committing now would stamp a broken snapshot onto your history. Throwing the edits away is unthinkable. You need to put this work down somewhere safe and come back to a clean folder.

Git gives you two shapes for "put it down." One parks your tracked edits off to the side, so those files return to exactly what your last commit held. The other leaves your folder untouched and hands you a *second* folder next door, checked out from your last commit on its own branch, two live copies of the project at once. They cost different things and they feel different. Run each one on the same half-finished folder and watch which one keeps your edits on screen while the fix happens.

ONE REPO, TWO WAYS TO STEP AWAY

Keep going, sign up to unlock the rest

4 more parts in this topic, plus 18+ more topics in Git.

Sign up, it's freeSee the full Git