Ask HN: Poll: Do you git stash your WIP?

3 points by tedmiston ↗ HN
For the unfamiliar, git stash [0] is a solution to a problem like this:

You're working on a feature, and suddenly realize the need to switch gears to work on something else — say a prod hotfix — and you need to store your WIP somewhere, but you're not ready to commit. You run `git stash` with an optional commit message and get back to business.

What happens for me is I end up making many small stashes across many projects. It might be a trivial change or a prototype of an idea, sometimes I forget creating them in the first place and implement the same thing again and/or they become stale.

My question for others is:

Do you use git stash? Do you forget them sometimes some?

For some more context: I'm pondering writing a little program to peruse all stashes from all repos on your drive in one place.

[0]: https://git-scm.com/docs/git-stash

6 comments

[ 6.3 ms ] story [ 22.1 ms ] thread
I use SmartGit, and it already shows a list of my stashes for any open repo (including the branch, the date, and the message on the stash, which functions as a name to remember what the contents are).
Only if I stash pop in a few minutes time (stash, quick fix another branch, stash pop) . Mostly commit, or move to new clone
I don't understand "not ready to commit"; what's the issue with interim commits? If you're working under a new branch, which you should be anyway, there's no harm, unless you squash them under inappropriate circumstances.
My thought is that these WIP comments remain in the log once a branch is merged into master (shared with the team) and it feels like a messy paper trail.

I am personally a fan of commit squashing, particularly small feature branches and/or when the commits in question are temporary like this. I try to leave a really clean commit log on each branch I work on knowing that it will be merged eventually. Sometimes I'll interactive rebase or rewrite history on these to make it that way.

Not everyone believes in that approach though.

git stash && git pull --rebase && git stash pop