Put this in the
[alias] section of your
wip = !git add -A && git commit -m "WIP"
Now you can
git wip instead of
git stash. All changes to the working tree
are recorded in a proper commit. When you’re ready to resume work, just do a
git reset HEAD^.
git stash is sometimes convenient, but the feature has some drawbacks.
- It’s easy to forget that you have something stashed
- Pushing multiple stashes on the stack doesn’t seem useful
- Untracked files are not stashed away
Storing all changes as a WIP commit is a simple way to leverage the “normal” git workflow to build a more powerful stashing feature.
I learned this trick, and several others, here.