How to color the Git console?

前端 未结 11 1089
借酒劲吻你
借酒劲吻你 2020-11-30 16:07

I recently saw that the git console in Windows is colored, e.g. Green for additions, red for deletions, etc. How do I color my git console like tha

相关标签:
11条回答
  • 2020-11-30 16:41

    In Ubuntu or any other platform (yes, Windows too!); starting git1.8.4, which was released 2013-08-23, you won't have to do anything:

    Many tutorials teach users to set "color.ui" to "auto" as the first thing after you set "user.name/email" to introduce yourselves to Git. Now the variable defaults to "auto".

    So you will see colors by default.

    0 讨论(0)
  • 2020-11-30 16:45

    Another way is to edit the .gitconfig (create one if not exist), for instance:

    vim ~/.gitconfig
    

    and then add:

    [color]
      diff = auto
      status = auto
      branch = auto
    
    0 讨论(0)
  • 2020-11-30 16:46

    GIT uses colored output by default but on some system like as CentOS it is not enabled . You can enable it like this

    git config --global color.ui  true 
    git config --global color.ui  false 
    git config --global color.ui  auto 
    

    You can choose your required command from here .

    Here --global is optional to apply action for every repository in your system . If you want to apply coloring for current repository only then you can do something like this -

     git config color.ui  true 
    
    0 讨论(0)
  • 2020-11-30 16:48

    Git automatically colors most of its output if you ask it to. You can get very specific about what you want colored and how; but to turn on all the default terminal coloring, set color.ui to true:

    git config --global color.ui true
    
    0 讨论(0)
  • 2020-11-30 16:50

    Add to your .gitconfig file next code:

    [color]
        ui = auto
    [color "branch"]
        current = yellow reverse
        local = yellow
        remote = green
    [color "diff"]
        meta = yellow bold
        frag = magenta bold
        old = red bold
        new = green bold
    [color "status"]
        added = yellow
        changed = green
        untracked = cyan
    
    0 讨论(0)
提交回复
热议问题