Changing "git status" output colors in Posh-Git
Asked Answered
S

5

84

In Posh-Git, when I run "git status" in a repository, the colors for changes and untracked files are dark red, when I have tried to configure them to be "normal" red. I want to do this because I have a console with a dark background, so dark red is difficult to read.

I searched around, and there seem to be two configuration changes which I needed to make:

  1. Change "WorkingForegroundColor" and "UntrackedForegroundColor" from "DarkRed" to "Red" in $GitPromptSettings.

  2. Change "color.status.changed" and "color.status.untracked" to red in git config.

From my reading, that's all I should need to do, and yet the results of "git status" remain dark red.

Here's a summary, to prove I set them as I claimed, and maybe someone can spot the error:

screenshot

Sarcenet answered 24/8, 2013 at 15:27 Comment(1)
The question is how did this theme, with this colors?Lienlienhard
I
66

There is only one way to change DarkRed to Red here: modify color scheme of console window itself. As far as I know git will pick "first" red on the list (that happens to be dark...). So just increase R value for it.

You can do it directly on window (Properties -> Colors) or in registry. Prompt is different story: it uses PS color names, where Red = Red, not DarkRed...

Ishmaelite answered 25/8, 2013 at 9:0 Comment(6)
This is great. I had no idea that the set of colors in properties was a color palette that everything would draw from.Chrome
I wont lie, I was pretty skeptical about changing the Red from the properties window...but, entirely accurate. Great answer =)Effeminacy
Works Great! Works for Powershell as well if you are using the standard console (not ISE). And it works for both the git status and posh-git. I just went to Properties -> Colors, clicked on the dark red and change its Red value to 255. Works fantastic now. Thanks a lot!Laszlo
Great help. I have been so annoyed at the red color status info. Has been trying to change it but doesn't work. Simply making red value to 15 working great to me.Lovel
Running powershell. Was Most helpful. Thanks.Revanche
I am deeply frustrated at how byzantine the colour config is in powershell. Really happy to have found this answer!Atp
L
142

The output of git status is controlled by your .gitconfig file. The default for changed and untracked files is a dim Red but you likely want Red Bold which is the bright (default) red you have in the prompt.

Add the following to your .gitconfig file:

[color]
    ui = true
[color "status"]
    changed = red bold
    untracked = red bold
    added = green bold

For anyone else referencing this in the future, the accepted colours are normal, black, red, green, yellow, blue, magenta, cyan, and white as well a single optional modifier bold, dim, ul, blink, or reverse. If two colours are given the first is the foreground, and the second is the background.

Lac answered 9/4, 2014 at 6:53 Comment(8)
Thank you -- my life is now complete! A note for anyone who may have problems getting this to work, it didn't work for me until I installed a newer version of posh-git.Orlan
This works for any version of git on windows, not just posh git.Entreaty
This works even on powershell. +1 for my productivity boost.Multipartite
Used the pattern git config <color-to-update> “foreground-color background-color attribute” like git config --global color.status.changed "cyan normal bold"Freddyfredek
What is ui=true? Check here, section colors.Cooperage
What is ul supposed to do with the colors? I can't tell a difference and it's not immediately obvious. The others are great: +1!Marks
This is an old answer, color.ui=true enables the invisible formatting characters that colors the output to console. From what I remember, this used to be false by default because it wasn't supported on some shells, but it appears that's no longer the case and it's likely unnecessary. With how popular this answer still is I should probably update it at some point.Lac
+1 on the comment above. Also, if people visit this in 2024 or later, please look at the answer from @Ishmaelite instead, which works for all git colors (even diff)Waggle
I
66

There is only one way to change DarkRed to Red here: modify color scheme of console window itself. As far as I know git will pick "first" red on the list (that happens to be dark...). So just increase R value for it.

You can do it directly on window (Properties -> Colors) or in registry. Prompt is different story: it uses PS color names, where Red = Red, not DarkRed...

Ishmaelite answered 25/8, 2013 at 9:0 Comment(6)
This is great. I had no idea that the set of colors in properties was a color palette that everything would draw from.Chrome
I wont lie, I was pretty skeptical about changing the Red from the properties window...but, entirely accurate. Great answer =)Effeminacy
Works Great! Works for Powershell as well if you are using the standard console (not ISE). And it works for both the git status and posh-git. I just went to Properties -> Colors, clicked on the dark red and change its Red value to 255. Works fantastic now. Thanks a lot!Laszlo
Great help. I have been so annoyed at the red color status info. Has been trying to change it but doesn't work. Simply making red value to 15 working great to me.Lovel
Running powershell. Was Most helpful. Thanks.Revanche
I am deeply frustrated at how byzantine the colour config is in powershell. Really happy to have found this answer!Atp
W
15

In addition of @WarrenB answer. To change the color of status and the color of the git diff (of new lines and removed lines) you have to have this in your .git/config file:

[color]
    ui = true
[color "status"]
    changed = red bold
    untracked = red bold
    added = green bold
[color "diff"]
    old = red bold
    new = green bold

The "diff" option enables you the bright (bold) red and green colors. Reference: https://git-scm.com/docs/git-config#git-config-colordiff

Wort answered 10/7, 2017 at 16:3 Comment(0)
L
14

To change the color of the listed untracked and modified files to the more readable yellow color, you can add this to your ~/.gitconfig file:

[color "status"]
    untracked = bold yellow
    changed = bold yellow

Also updating you GitPrompt.ps1 to show untracked as yellow is then probably a good idea:

    UntrackedForegroundColor  = [ConsoleColor]::Yellow
    WorkingForegroundColor    = [ConsoleColor]::Yellow

Edit: GitPrompt.ps1 is found in the PowerShell posh-git folder.

Lias answered 5/12, 2013 at 8:40 Comment(1)
This is a great answer with far less complexity and 3rd party stuff. It's +1 definitely. However, I'd like to see two more things there. First one being a reference to and a full listing of other properties that are settable in the term of a color (if there are any). Second one is a suggestion how to set an arbitrary color (preferably a hexa-value but a list of available color numerals is great too). The second one is, of course, if it is possible (and in my experience, it's a pretty large "if".)Marks
M
8

You can change these by modifying the source of the GitPrompt.ps1 file in the PowerShell posh-git module folder. I had the same issue and just removed the 'Dark' in the colors defined around line 30 in this file:

BeforeIndexForegroundColor= [ConsoleColor]::**Green**
BeforeIndexBackgroundColor= $Host.UI.RawUI.BackgroundColor

IndexForegroundColor      = [ConsoleColor]::**Green**
IndexBackgroundColor      = $Host.UI.RawUI.BackgroundColor

WorkingForegroundColor    = [ConsoleColor]::**Red**
WorkingBackgroundColor    = $Host.UI.RawUI.BackgroundColor

UntrackedText             = ' !'
UntrackedForegroundColor  = [ConsoleColor]::**Red**

This list of Powershell colors is also useful.

Mousse answered 31/10, 2013 at 20:17 Comment(3)
This worked for changing the colors on the command prompt which shows the abbreviated status (example: [master +1 ~0 -0 | +2 ~0 ~0]). But it did not change the colors output by the "git status" command. BartekB's suggestion did not change either.Regardant
worked for me in both locations, but only after getting the latest version of posh-gitOrlan
worked fine for me with powershell and just standard git from git Bash (what is Posh anyway lol)Freedafreedman

© 2022 - 2024 — McMap. All rights reserved.