Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

See what's in a stash without applying it [duplicate]

Tags:

git

git-stash

I see here you can apply/unapply a stash and even create a new branch off of a stash. Is it possible to simply see what is inside the stash without actually applying it?

like image 743
Chris Abrams Avatar asked May 23 '12 18:05

Chris Abrams


People also ask

How can I see my stash changes without applying?

git stash show -p stash@{0} --name-only shows just the names of the files (not the contents) in your first stash. @mrgloom If you want to see the stashed changes for a single file, then something like git diff stash@{0}^! -- file. txt will do it.

How do you show the details of a stash as a difference?

Show the changes recorded in the stash as a diff between the stashed state and its original parent. When no is given, shows the latest one. 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).

How do I view contents in stash?

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.

How do I see untracked files in stash?

Stash entries can be made with untracked files via git stash push --include-untracked (man). However, because the untracked files are stored in the third parent of the stash entry and not the stash entry itself, running git stash show (man) does not include the untracked files as part of the diff.


1 Answers

From man git-stash (which can also be obtained via git help stash):

The modifications stashed away by this command can be listed with git stash list, inspected with git stash show, and ...

show [<stash>]     Show the changes recorded in the stash as a diff between the stashed     state and its original parent. When no <stash> is given, shows the     latest one. 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). 

Note: the -p option generates a patch, as per git-diff documentation.

List the stashes:

git stash list 

Show the files in the most recent stash:

git stash show 

Show the changes of the most recent stash:

git stash show -p 

Show the changes of the named stash:

git stash show -p stash@{1} 
like image 120
simont Avatar answered Oct 01 '22 12:10

simont