According to the git docs, git stash list
will accept any of the options that you could pass to git log
.
What I want to do is to pass the --stat
option to git stash list
. This works, however it seems to show the every file in the repo.
Now, I know there's a git stash show
which will show just those files that have been changed, but I then need to manually go through and inspect each one.
Is there any way to get git to show me the list of stashes, with just the changes that were stashed for each one?
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.
git stash show -p stash@{0} --name-only shows just the names of the files (not the contents) in your first stash. @mrgloom If you want to see the stashed changes for a single file, then something like git diff stash@{0}^! -- file. txt will do it.
To stash a specific file, use the “git stash push” command and specify the file you want to stash. However, the other tracked files that may be modified in your current working directory are untouched.
Git Stash List (Check the Stored Stashes) To check the stored stashes, run the below command: Syntax: $ git stash list.
Update for Git v2.2 onwards:
git stash list --stat
works.
Things have changed since the question was asked and OP's dilemma no longer applies. From Git v2.2 onwards, you can simply pass --stat
to git stash list
and it will behave as intuitively expected.
You can also use any of the other file listing options such as --name-status
, --name-only
and --raw
available to git log
.
The original answer below applies if you're using a version of Git prior to v2.2.
Original answer:
Like this I guess:
git stash list | while IFS=: read STASH ETC; do echo "$STASH: $ETC"; git diff --stat $STASH~..$STASH --; done
(Tested in Git Bash msysgit.)
git stash show $STASH
instead of git diff --stat $STASH~..$STASH
also worked but was unbearably slow.
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