Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git: List just the files modified for all stashes

Tags:

git

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?

like image 932
Nate Cavanaugh Avatar asked Feb 06 '13 18:02

Nate Cavanaugh


People also ask

How do I see stash list changes?

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.

How can I see my stash changes without applying?

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.

How do I stash a list of files in git?

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.

What is the command to see all the saved stashes in a repository?

Git Stash List (Check the Stored Stashes) To check the stored stashes, run the below command: Syntax: $ git stash list.


1 Answers

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.

like image 67
antak Avatar answered Oct 07 '22 20:10

antak