How can I see the changes un-stashing will make to the current working tree? I would like to know what changes will be made before applying them!
If you created the stash from master (to save work for later), then do some commits for other work on master, then do git diff stash@{0} master , you get a diff of your stash against the current master (which includes the work done on master after the stash was made), not the files/lines that the stash would change, ...
The git commit and git stash commands are similar in that both take a snapshot of modified files in the git working tree and store that snapshot for future reference. The key differences between the two are as follows: A commit is part of the public git history; a stash is stored locally.
The Git stash list command will pull up a list of your repository's stashes. Git will display all of your stashes and a corresponding stash index. Now, if you wish to view the contents of a specific stash, you can run the Git stash show command followed by stash@ and the desired index.
To pop a specific stash in git, you can use the git stash apply command followed by the stash@{NUMBER} command. command. It will show the list of stashes you have saved.
See the most recent stash:
git stash show -p
See an arbitrary stash:
git stash show -p stash@{1}
From the git stash
manpages:
By default, the command shows the diffstat, but it will accept any format known to git diff (e.g., git stash show -p stash@{1} to view the second most recent stash in patch form).
To see the most recent stash:
git stash show -p
To see an arbitrary stash:
git stash show -p stash@{1}
Also, I use git diff to compare the stash with any branch.
You can use:
git diff stash@{0} master
To see all changes compared to branch master.
Or You can use:
git diff --name-only stash@{0} master
To easy find only changed file names.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With