Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can git do a diff of the working copy with stash

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.

like image 673
Laughing monster Avatar asked Nov 08 '11 23:11

Laughing monster


People also ask

What happens if you git stash twice?

If you made two stashes, then just call git stash pop twice. As opposed to git stash apply , pop applies and removes the latest stash. You can also reference a specific stash, e.g.

What happens when I git stash?

git stash temporarily shelves (or stashes) changes you've made to your working copy so you can work on something else, and then come back and re-apply them later on.

Can you git stash just one file?

To stash a specific file, use the “git stash push” command and specify the file you want to stash. However, the other tracked files that may be modified in your current working directory are untouched.


1 Answers

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 
like image 105
Andy Avatar answered Sep 19 '22 15:09

Andy