Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git stash doesn't show with me after i stash save a untracked file

Tags:

git

git stash doesn't show untracked files after I use git stash save -u:

D:\kzxd-usm\KzxdUsm>git status
Already up-to-date!
# On branch work
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       WebRoot/WEB-INF/jsp/usm/org/Copy of list.jsp
nothing added to commit but untracked files present (use "git add" to track)

I want list the untracked file after it's stashed with git stash save -u:

D:\kzxd-usm\KzxdUsm>git stash list --stat
stash@{0}: On work: hide copy of list.jsp

It has only a little comment text and does not have stashed file information.

like image 720
lyrl Avatar asked Aug 16 '13 08:08

lyrl


4 Answers

In my 1.7.8.2, stash@{0}^3 does not work to show untracked files. However, I have found that the following does list them in the the second log entry:

git log -2 --name-only stash@{0}

You can use -p instead of --name-only if you want to see the file details.

like image 22
David Avatar answered Sep 28 '22 09:09

David


If you stash with git stash save -u and then do git stash show, untracked files will not be shown -- the listing will contain changes to tracked files only.

It makes sense when you want to share your stashed changes with someone: The diff you get from git stash show won't contain any extra garbage (the untracked stuff from your working copy) but only the relevant changes to tracked files.

Once you restore your stashed changes with git pop, the untracked files will be restored as well.

like image 24
huoneusto Avatar answered Sep 28 '22 08:09

huoneusto


The best answer I found is at In git, is there a way to show untracked stashed files without applying the stash? and this answer in particular - https://stackoverflow.com/a/23712152/1019307.

git rev-list -g stash | git rev-list --stdin --max-parents=0 | xargs git show --stat
like image 38
HankCa Avatar answered Sep 28 '22 07:09

HankCa


use git show stash@{0}^3 to show all the untracked files stashed.

like image 138
nakeer Avatar answered Sep 28 '22 07:09

nakeer