Git pretty format colors

前端 未结 5 734
醉酒成梦
醉酒成梦 2020-12-07 09:36

I\'m trying to set up pretty format colors for Git. From what I can tell version 1.6.0 only recognizes red, green and blue.

$ git log --pretty=format:\"%Cre         


        
5条回答
  •  生来不讨喜
    2020-12-07 09:44

    Here are two aliases that I wrote once I understood the syntax of using custom hexadecimal color values as shown in @VonC 's answer.

    There are four versions, the only difference is the --graph directive and the 'f' versions will also show you files that were added, deleted or modified:

    [alias]
        lg = log --graph --pretty=format:"%C(#cd9a00)%h\\%C(#0080ff)\\ <%an>\\ %C(#17b062)(%cr)\\ %d\\%C(#c0d6de)%s"    
        l1 = log --pretty=format:"%C(#cd9a00)%h\\%C(#0080ff)\\ <%an>\\ %C(#17b062)(%cr)\\ %d\\%C(#c0d6de)%s"    
        lgf = log --name-status --graph --pretty=format:"%C(#cd9a00)%h\\%C(#0080ff)\\ <%an>\\ %C(#17b062)(%cr)\\ %d\\%C(#c0d6de)%s" 
        l1f = log --name-status --pretty=format:"%C(#cd9a00)%h\\%C(#0080ff)\\ <%an>\\ %C(#17b062)(%cr)\\ %d\\%C(#c0d6de)%s"
    

    I used this site to pick the exact colors I wanted and then copied the hex value from it:

    https://www.colorhexa.com/

    For Windows, open up your .gitconfig file that resides in your "C:\Users\YourUserName" Folder and add an alias section as depicted above.

    Hope you like them.

提交回复
热议问题