Show all stashes in git log

后端 未结 7 2040
一个人的身影
一个人的身影 2021-01-31 07:27

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 log all commits. I use the command

相关标签:
7条回答
  • 2021-01-31 07:57

    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

    0 讨论(0)
  • 2021-01-31 08:05

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

    0 讨论(0)
  • 2021-01-31 08:08

    Another easy way to do this is git reflog show stash

    0 讨论(0)
  • 2021-01-31 08:12

    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).


    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?

    0 讨论(0)
  • 2021-01-31 08:12

    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).

    0 讨论(0)
  • 2021-01-31 08:20

    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.

    0 讨论(0)
提交回复
热议问题