82

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

NightShovel
  • 3,032
  • 1
  • 31
  • 35

5 Answers5

141

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.

WarrenB
  • 2,145
  • 3
  • 14
  • 18
  • 1
    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. – ckapilla Apr 24 '16 at 21:55
  • 5
    This works for any version of git on windows, not just posh git. – Michael Landes Apr 28 '16 at 04:19
  • 5
    This works even on powershell. +1 for my productivity boost. – Click Ok Nov 06 '16 at 01:50
  • 5
    Used the pattern `git config “foreground-color background-color attribute”` like `git config --global color.status.changed "cyan normal bold"` – Matthew McDermott Sep 07 '18 at 15:17
  • What is ui=true? Check [here](https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration), section colors. – Timo Oct 25 '20 at 13:38
  • 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! – Konrad Viltersten Aug 07 '21 at 08:58
  • 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. – WarrenB Aug 08 '21 at 16:41
64

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...

BartekB
  • 8,492
  • 32
  • 33
  • 3
    This is great. I had no idea that the set of colors in properties was a color palette that everything would draw from. – Ben Wilde Oct 14 '15 at 16:10
  • 2
    I wont lie, I was pretty skeptical about changing the Red from the properties window...but, entirely accurate. Great answer =) – afreeland Sep 22 '16 at 19:30
  • 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! – Tolga Mar 20 '17 at 20:43
  • 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. – Charasala Feb 03 '18 at 22:13
  • Running powershell. Was Most helpful. Thanks. – jdawiz Jan 30 '19 at 17:52
  • I am deeply frustrated at how byzantine the colour config is in powershell. Really happy to have found this answer! – Gershom Maes Apr 24 '20 at 18:37
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.

arberg
  • 4,148
  • 4
  • 31
  • 39
Thomas Svensen
  • 760
  • 1
  • 7
  • 14
  • 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*".) – Konrad Viltersten Aug 07 '21 at 08:25
14

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

Luigi Lopez
  • 1,037
  • 10
  • 23
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.

Ade Miller
  • 13,575
  • 1
  • 42
  • 75
  • 2
    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. – John Pankowicz Nov 26 '13 at 16:18
  • worked for me in both locations, but only after getting the latest version of posh-git – ckapilla Apr 24 '16 at 21:55
  • worked fine for me with powershell and just standard git from git Bash (what is Posh anyway lol) – Stéphan Champagne Apr 28 '20 at 13:45