简体   繁体   中英

Git colors don't display in Windows command prompt

I assume that it's because of the color setting in my config file, but I've tried changing that to no avail. Maybe I'm not doing that right?

Notice that Git Bash shows branch color in green, but on window cl it's not showing at all!

在此输入图像描述

$ git branch
* add_bower *<~~~ only the asterisk appears on the windows prompt.*
  master

git in cmd should work just fine. I would check both your gitconfig local and gitconfig global before giving up here.

the first thing I would do is a

git branch --color

or

git diff --color

you can also use the -c option

git -c color.ui=always status

if you see colors then what is likely happening is your local gitconfig is overriding the setting in your global gitconfig

at that point do a

git config --local --edit

if things say auto or true and you still don't see colors. set the output to always. I recommend this b\\c it is possible for git to make mistakes and not treat cmd as a terminal

from git-config :

If this is set to always, git-diff(1), git-log(1), and git-show(1) will use color for all patches. If it is set to true or auto, those commands will only use color when output is to the terminal. Defaults to false.

like so

[color]
    branch = always
    diff = always
    interactive = always
    status = always
    ui = always

hope this helps!

I don't think the command prompt will support coloring different parts of the output out of the box. You'd probably need some extension or add-on to handle it. Have you considered using Powershell ? In addition to the built-in support for the coloring you're looking for, it's also much more versatile and powerful than the normal command prompt. 在Powershell中以颜色输出

I'm seeing the exact same problem, only for some command prompts. (By default it works, but when I run my team's "razzle" customization script the output is broken like your screenshot. Oddly, coloring in git log and status works fine; just branch is broken.)

I created a new shortcut that launched the same customization script, and the output is fixed for my new shortcut. Very weird.


If you run git branch --no-color you see the right output, just without color?

You can run git config --local --add color.branch never to set that as the default for this repo.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM