How To See Git Stash Changes
March 24, 2020
git
Show most recent stash's contents
If you want jus the most recent changes then run the following command:
bash
1.git stash show -p
Show specific stash contents
To get the contents of a specific stash in your stash history you need to pass in the reference value for that particular stash.
bash
1.git stash show {stashRef} -p
You can see the stashRef
s, along with all the stashes you currently have, by using the following command:
bash
1.git stash list
For example,
bash
1.❯ git stash list2.stash@{0}: WIP on master: 8382b08 change menu icon to close3.stash@{1}: WIP on visualizing-apple: 0d32414 first draft of visualizing apple
The stashRef
value is stored in the @{stashRef}
, in this case, 0
and 1
. If we want to see the contents of the second stash we would type:
bash
1.git stash show 1 -p
This will give you a diff of changes for that stash:
bash
1.diff --git a/package-lock.json b/package-lock.json2.index 3eb2707..71465d5 1006443.--- a/package-lock.json4.+++ b/package-lock.json5.@@ -14170,6 +14170,11 @@6. "scheduler": "^0.18.0"7. }8. },9.+ "react-render-to-json": {10.+ "version": "0.0.6",11.+ "resolved": "https://registry.npmjs.org/react-render-to-json/-/react-render-to-json-0.0.6.tgz",12.+ "integrity": "sha512-fMfqnDjO2HHeg3k4dVierDxVQUymaTfWlsL9pfkSNHpXhGey1J/T8CDsVhN+xjswFYSM30zL0dLBiGHqGoAWWg=="13.+ },