Using the command line tool git-stash
, how can I view both the stash message, as well as the diff, for a given stash?
The documentation for git stash mentions that you can configure how a diff is shown, but it doesn't mention messages anywhere other than in how to create a stash.
The command git-diff is also one of common command which is used to show changes between commits, commit and working tree, etc. By default, git diff will show the diff of selected stash against(modified files) current state of repository unless other stash reference or commit is specified.
Git Stash Save (Saving Stashes with the message): In Git, the changes can be stashed with a message. To stash a change with a message, run the below command: Syntax: $ git stash save "<Stashing Message>"
To retrieve changes out of the stash and apply them to the current branch you're on, you have two options: git stash apply STASH-NAME applies the changes and leaves a copy in the stash. git stash pop STASH-NAME applies the changes and removes the files from the stash.
The Git stash list command will pull up a list of your repository's stashes. Git will display all of your stashes and a corresponding stash index. Now, if you wish to view the contents of a specific stash, you can run the Git stash show command followed by stash@ and the desired index.
A stash is stored as a normal commit, hence you can use usual Git commands to display it, like:
git show stash@{1}
to show message and diff for stash@{1}
. Since stashes are stored as commits with two parents (one for the index, and the other for the HEAD
at the time the stash was created), the command above will show a combined diff.
Obviously, as others already pointed out, git stash list -p
or git list
with stash.showPatch=true
(new in 2.7.0) also show diff + message, for all stashes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With