wincent Wincent Colaiuta's weblog

« New iMac "Superdrive" | Main | Anchor »

September 4, 2007

Stash

Git 1.5.3 just came out a few days ago and one of the greatest things about it is the addition of the git stash command. This addresses one of the most annoying workflow obstacles that I run into many times each day: working on a particular task that may take minutes, hours or even days, and stumbling across something else that could be fixed along the way in a matter of minutes.

Faced with such a discovery there are four options:

All of these work to some degree but have their drawbacks. You either wind up with a desk or notebook full of notes, create an unclean history that conflates separate changes and makes it harder to "cherry pick", have to plod through the unwieldy-yet-powerful git add --interactive interface, or issue far too many commands for managing and merging branches when what you really want to do is much simpler.

All of this goes away with git stash. Now your workflow looks like this:

And the commands to do so are simple and easy to remember (git stash, git stash apply, git stash clear). As with many other things in Git, it's quite sophisticated and powerful — it's actually a stack of stashes so you can have multiple things stashed away at once — but the basic use case is very straightforward.

I've been looking forward to 1.5.3 for some time now for exactly this reason.

More Development articles

Posted by wincent at September 4, 2007 4:32 PM