Show all stashes in git log

后端 未结 7 2130
一个人的身影
一个人的身影 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 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?

提交回复
热议问题