Showing branch hierarchy at the command line?

后端 未结 6 1664
攒了一身酷
攒了一身酷 2021-01-29 23:53

I\'m curious if there is a way to show branch hierarchy on the command line? For instance if I use git branch, instead of seeing output like this:

*         


        
6条回答
  •  无人共我
    2021-01-30 00:26

    I want to complete the answer of @ctcherry.

    I like when I can also see the user who did the commit and the date, so this is the following line to use :

    git log --all --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
    

    However this is a pretty long line and difficult to memorize so you can use an alias. You just have to use this in your terminal :

    git config --global alias.lg "HERE GOES MY BIG LOG COMMAND LINE"


    To summarize copy and paste the line below on your terminal:

    git config --global alias.lg "log --all --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
    

    Then you will just have to use git lg to get your log history tree.

    Example:

    src

提交回复
热议问题