As I find myself relying more on stashing in Git, I’ve realized that the default output of git stash list isn’t always the most helpful:
$ git stash list
stash@{0}: WIP on feature1: b50788b… First pass…
stash@{1}: WIP on master: b50788b… First pass…
stash@{2}: WIP on shoulda: e783fb0… Upgrading the rest…
While it does display the commit SHA and message that your work was based off of, it often leaves me scratching my head trying to recall the specific changes I stashed away. This is especially true when juggling multiple tasks or bug fixes.
A smarter approach is to stash with a meaningful message:
git stash save "your message here"
Now, your stashes will have clear and descriptive messages, making it easier to identify their contents:
$ git stash list
stash@{0}: On shoulda: Updating instructions
stash@{1}: On master: started merge but need to fix #104 first
stash@{2}: On feature1: Adding some stuff
When you need to revisit a particular stash to review its changes, simply pass the stash reference (e.g., stash@{0}) into git diff:
$ git diff stash@{0}
diff --git a/TODO b/TODO
index b0ecaeb..4ca398c 100644
--- a/TODO
+++ b/TODO
@@ -1,4 +1,3 @@
[ ] Easier configuration of Maruka and blahtex directories [mdreid]
[ ] Accurate "related posts" calculator
-[ ] Autobuild
-[ ] Add more awesome.
+[ ] Autobuild
\ No newline at end of file
Additionally, you can use git show to view the commit the stash was based on.
By implementing these strategies, you can streamline your stashing workflow and save valuable time. Have more stash-related tips or other insights? Feel free to share them with us!