Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save stoffeastrom/aec99e530e19bead7a3d9e1549dfc8fd to your computer and use it in GitHub Desktop.
Save stoffeastrom/aec99e530e19bead7a3d9e1549dfc8fd to your computer and use it in GitHub Desktop.
How to show git stash untracked files

REF: https://stackoverflow.com/a/12681856

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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment