Can git do a diff of the working copy with stash

Laughing monster picture Laughing monster · Nov 9, 2011 · Viewed 19.8k times · Source

How can I diff my current working copy against a stash?

My use case: my working copy already contains a subset of the changes in my stash@{0}, but I don't want to apply all the changes in stash@{0}. I want to do a diff to help determine which desirable changes in stash@{0} are still missing from my working copy.

Answer

Andy picture Andy · Nov 9, 2011

If it was your most recent stash, git diff stash@{0} will do it. If not, you can use git stash list to get the index of which stash you want to compare to.

To see the difference between the actual working copy and the stash you would need to commit it first. You could then rollback the commit.

git add -A                   <- Add all the files
git commit -m "temp"         <- commit them
git diff stash@{0}..HEAD     <- diff the commit with your stash
git reset HEAD~              <- roll your commit back