Changing "git status" output colors in Posh-Git

GitPowershellWindows 7Posh Git

Git Problem Overview


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

Git Solutions


Solution 1 - Git

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.

Solution 2 - Git

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

Solution 3 - Git

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.

Solution 4 - Git

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

Solution 5 - Git

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionNightShovelView Question on Stackoverflow
Solution 1 - GitWarrenBView Answer on Stackoverflow
Solution 2 - GitBartekBView Answer on Stackoverflow
Solution 3 - GitThomas SvensenView Answer on Stackoverflow
Solution 4 - GitLuigi LopezView Answer on Stackoverflow
Solution 5 - GitAde MillerView Answer on Stackoverflow