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?
If I run git stash -u , I can stash untracked files. However, said
Share
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-stashphrases things… or just by doinggit log --graph 'stash@{0}')You can view just the "untracked" portion of the stash via:
or, just the "untracked" tree itself, via:
or, a particular "untracked" file in the tree, via:
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 asstash@{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".