Show all stashes in git log

GitGit LogGit Stash

Git Problem Overview


I would like to see all stashes in git log output. Does anyone know if there is a way to do that?

Edit: I want to see all commits in the log -- including stash commits. I tried the command:

git log --date-order --all

But it returns only the top most stash. I would like to see commits that represent other stashes too.

Git Solutions


Solution 1 - Git

You can show all your stashes with git stash list. Maybe you can write a script to show both git stash list and git log and use it with an alias.

Solution 2 - Git

I came here looking to do the same as @jbialobr, I did some more digging after reading the previous answers and came up with the below.

@msmt's answer gives you a log of the stashes, and you can use this to get the hashes to use in the git log.

git reflog show --format="%h" stash gives you just the hashes of all stashes which can then be passed to a git log command such as

git log --date-order --all $(git reflog show --format="%h" stash)

The full command I personally am now using is

git log --oneline --graph --decorate --all $(git reflog show --format="%h" stash)

Tested on git version 2.5.1 on centos

Solution 3 - Git

Not sure what you mean. stash is a branch and you can list all stashes with git log -g stash.

Solution 4 - Git

Another easy way to do this is git reflog show stash

Solution 5 - Git

Full command:

git log --oneline --graph --all $(git stash list --format="%H")

Where list of heads of stashes:

git stash list --format="%H"

Solution 6 - Git

To get the tree graph with everything: all branches, all stashes at your fingertips...


Expanding on a super-useful answer from SicoAnimal, so you don't have to type out all this stuff (especially useful with remote SSH sessions where you don't have any kind of Git UI)...


1. Setup git aliases:

# Short and sweet: hashes and graph with all branches and stashes
git config --global alias.l \
    '!sh -c '"'"' git log --oneline --graph --all --decorate $(git reflog show --format="%h" stash --) '"'"' '

# Same as above + dates and emails
git config --global alias.ll \
    '!sh -c '"'"' git log --graph --all --date=format:"'"%Y-%m-%d %H:%M"'" --pretty=format:"'"%C(yellow)%h%Creset%C(auto)%d%Creset %C(cyan)%cd%Creset %s %C(green)(%ce)%Creset"'" $(git reflog show --format="%h" stash --) '"'"' '

2. Use aliases:

# Short and sweet: hashes and graph with all branches and stashes
git l

# Same as above + dates and emails
git ll

3. Sweet result:

Notice that you can see all stashes, not only the latest one on a the given commit (shown with arrows).

enter image description here


Room for improvement:

# In case there are no stashes you get one-liner error message.
# The rest works as expected. Not sure how to fix it.
me@mymachine:~/projects/experiment/latest-angular-ten$ git l
fatal: bad revision 'stash'
* 00a696b (HEAD -> master) initial commit


References:

How to create a Git alias with nested commands with parameters?

Solution 7 - Git

For git version 2.2.3 or later, you can simply use the --reflog option of git log.

git log --graph --oneline --all --reflog

In addition, it also shows dangling commits.

Solution 8 - Git

If you can afford having a graphical GUI, take a look at gitk.

It shows you branches, tags, remote branches stashes etc. In a visually not appealing, but very compact and useful form. It usually comes along with "git" package in your package manager and works if you also have "tk" (the GUI toolkit it uses).

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionjbialobrView Question on Stackoverflow
Solution 1 - GitmgarciaisaiaView Answer on Stackoverflow
Solution 2 - GitSicoAnimalView Answer on Stackoverflow
Solution 3 - GitrobinrView Answer on Stackoverflow
Solution 4 - GitMichaelView Answer on Stackoverflow
Solution 5 - GitAndrey BochkovView Answer on Stackoverflow
Solution 6 - GitAndrei SinitsonView Answer on Stackoverflow
Solution 7 - GitM Imam PratamaView Answer on Stackoverflow
Solution 8 - GitVasiliNovikovView Answer on Stackoverflow