Can git do a diff of the working copy with stash

Solution 1:

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

Solution 2:

If your working tree is dirty, you can compare it to a stash by first committing the dirty working tree, and then comparing it to the stash. Afterwards, you may wish to undo the commit of your working tree (to keep your history clean).

  • Commit your dirty working tree:

    git add .
    git commit -m "Dirty commit"
    
  • Diff the stash with that commit:

    git diff stash@{0}
    
  • Then, afterwards, you may revert the commit, and put it back in the working dir:

    git reset --soft HEAD~1
    git reset .
    

Now you've diffed the dirty working tree with your stash, and are back to where you were initially.