The following command can be used to extract diff of stashed change against any other stash or commit or branch or HEAD.
git stash show
git show
git diff
git difftool
Let’s see, how we can use each of the above mentioned commands.
git stash show
The simple command git stash show gives very brief summary of changes
of file, but will not show the diff of changes against current HEAD.
git show
The command git-show is used to see various types of objects.
The command git-show is not only used to visualize stash changes, but
also used to see one or more objects like blobs, trees, tags and
commits.
git diff
The command git-diff is also one of common command which is used to
show changes between commits, commit and working tree, etc.
By default, git diff will show the diff of selected stash
against(modified files) current state of repository unless other stash
reference or commit is specified.
To get difference between top most stash stash@{0}
and master
branch:
git diff stash@{0} master
Only display the names of file not diff of changes:
git diff --name-only stash@{0} master
See the diff between selected stashes for a selected file:
git diff stash@{0}^1 stash@{0} -- <filename>
git difftool
The command git-difftool can also be used to find diff between
selected stash and selected commit or branch or stash
See the difference between latest two stashes:
git difftool stash@{0} stash@{0}^1
git difftool --dir-diff stash@{0} stash@{0}^1
Summary:
Commands which are useful to extract the diff from selected stash: git stash show
, git show
, git diff
, git difftool
.
See difference using command git stash show
,
git stash show -p stash@{0}
See the changes in the stash using command git show
,
git show stash@{1}
See the difference between latest stash and selected commit using command git diff
,
git diff stash@{0} <commit-hash>
References:
https://howto.lintel.in/how-to-see-stashed-changes-using-git-stash/
https://git-scm.com/docs/git-show
https://git-scm.com/docs/git-stash
git stash show -p stash@{1} >~/.diff && vim ~/.diff
(doesn't have to bevim
. any text editor as long as your text editor has syntax highlighting support fordiff
output).