Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show message as well as diff with git stash show

Tags:

git

git-stash

Using the command line tool git-stash, how can I view both the stash message, as well as the diff, for a given stash?

The documentation for git stash mentions that you can configure how a diff is shown, but it doesn't mention messages anywhere other than in how to create a stash.

like image 649
Andrew Grimm Avatar asked Sep 27 '15 23:09

Andrew Grimm


People also ask

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

The command git-diff is also one of common command which is used to show changes between commits, commit and working tree, etc. By default, git diff will show the diff of selected stash against(modified files) current state of repository unless other stash reference or commit is specified.

Can you git stash with a message?

Git Stash Save (Saving Stashes with the message): In Git, the changes can be stashed with a message. To stash a change with a message, run the below command: Syntax: $ git stash save "<Stashing Message>"

How do I pop changes after git stash?

To retrieve changes out of the stash and apply them to the current branch you're on, you have two options: git stash apply STASH-NAME applies the changes and leaves a copy in the stash. git stash pop STASH-NAME applies the changes and removes the files from the stash.

How do you show stashed changes?

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.


1 Answers

A stash is stored as a normal commit, hence you can use usual Git commands to display it, like:

git show stash@{1}

to show message and diff for stash@{1}. Since stashes are stored as commits with two parents (one for the index, and the other for the HEAD at the time the stash was created), the command above will show a combined diff.

Obviously, as others already pointed out, git stash list -p or git list with stash.showPatch=true (new in 2.7.0) also show diff + message, for all stashes.

like image 96
Matthieu Moy Avatar answered Oct 26 '22 16:10

Matthieu Moy