If I run git stash -u
, I can stash untracked files. However, said untracked files don't show up at all with git stash show stash@{0}
. Is there any way to show untracked stashed files without applying the stash?
Untracked files are stored in the third parent of a stash commit. (This isn't actually documented, but is pretty obvious from The commit which introduced the -u feature, 787513..., and the way the rest of the documentation for git-stash
phrases things... or just by doing git log --graph stash@{0}
)
You can view just the "untracked" portion of the stash via:
git show stash@{0}^3
or, just the "untracked" tree itself, via:
git show stash@{0}^3:
or, a particular "untracked" file in the tree, via:
git show stash@{0}^3:<path/to/file>
There is, unfortunately, no good way to get a summary of the differences between all staged+unstaged+untracked vs "current" state. ie: git show stash@{0}
cannot be made to include the untracked files. This is because the tree object of the stash commit itself, referred to as stash@{0}:
, does not include any changes from the third, "unstaged" parent.
This is due to the way stashes are re-applied: tracked files can be easily applied as patches, whereas untracked files can only be applied, in theory, as "whole files".