How to Fix git log Output Encoding Issues: Properly Display Diacritical Characters in Windows 10 CLI Terminal

If you’ve ever run git log in the Windows Command Prompt, PowerShell, or even Git Bash and seen garbled text like Café instead of Café, naïve instead of naïve, or curaçao as curaçao, you’re facing a git log encoding issue. These problems arise when diacritical characters (accents, umlauts, cedillas, etc.)—common in languages like French, Spanish, German, or Portuguese—aren’t displayed correctly due to mismatched character encoding between Git and your terminal.

Git natively uses UTF-8 (Unicode) to store commit messages and metadata, but older Windows terminals (like Command Prompt) historically default to legacy encodings (e.g., CP437 or CP1252). This mismatch causes UTF-8 characters to be misinterpreted, resulting in "mojibake" (garbled text).

In this guide, we’ll demystify the root causes of encoding issues and walk through step-by-step solutions to ensure git log displays diacritical characters correctly in Windows 10. We’ll cover fixes for Command Prompt, PowerShell, and the modern Windows Terminal, along with Git configuration tweaks.

Table of Contents#

  1. Understanding the Encoding Problem
  2. Prerequisites
  3. Step-by-Step Solutions
  4. Advanced Troubleshooting
  5. Conclusion
  6. References

1. Understanding the Encoding Problem#

To fix encoding issues, it helps to first understand why they occur:

  • Git’s Default Encoding: Git stores commit messages, branch names, and file paths in UTF-8 (Unicode), a universal encoding that supports all languages. This is non-negotiable for Git’s internal operations.
  • Windows Terminal Defaults: Older Windows terminals (Command Prompt, legacy PowerShell) default to legacy encodings like:
    • CP437 (Code Page 437): Used in older DOS systems, limited to 256 characters (no diacritics).
    • CP1252 (Windows-1252): Western European encoding, supports some diacritics but not all Unicode characters.
  • Mismatch = Garbled Text: When Git outputs UTF-8 text to a terminal using CP437/CP1252, the terminal misinterprets UTF-8 bytes, leading to mojibake. For example, the UTF-8 byte sequence for é (0xC3 0xA9) is read as é in CP1252.

2. Prerequisites#

Before starting, ensure you have:

  • Git installed (version 2.18+ recommended; older versions may lack key UTF-8 settings). Download from git-scm.com.
  • Access to a Windows 10 terminal: Command Prompt, PowerShell, or the newer Windows Terminal (recommended).
  • Basic familiarity with CLI commands (e.g., git config, chcp).

3. Step-by-Step Solutions#

Follow these steps in order to resolve encoding issues. Start with Git configuration, then adjust your terminal, and verify with a test commit.

3.1 Configure Git to Enforce UTF-8 Output#

Git has built-in settings to control how it outputs text. Enforce UTF-8 for git log and other commands with these global configurations:

3.1.1 Set i18n.logOutputEncoding#

This tells Git to explicitly use UTF-8 when printing log messages. Run:

git config --global i18n.logOutputEncoding utf-8  

3.1.2 Disable Path Quoting for Non-ASCII Characters#

Git sometimes quotes paths/names with non-ASCII characters, which can trigger encoding issues. Disable this with:

git config --global core.quotepath false  

3.1.3 Verify Git Config#

Check that the settings were applied:

git config --global --list | grep -E "i18n.logOutputEncoding|core.quotepath"  

Expected output:

i18n.logoutputencoding=utf-8  
core.quotepath=false  

3.2 Fix Terminal Encoding (Command Prompt & PowerShell)#

Even with Git configured for UTF-8, your terminal must also use UTF-8 to display characters correctly.

3.2.1 For Command Prompt (CMD)#

The Command Prompt uses a "code page" to define its encoding. Switch it to UTF-8 (code page 65001) and set a Unicode-friendly font:

Step 1: Change the Code Page to UTF-8#

Run this command in CMD to switch to UTF-8:

chcp 65001  

(65001 is the code page identifier for UTF-8.)

To make this permanent (so you don’t run chcp 65001 every time):

  1. Open RegEdit (press Win + R, type regedit, and hit Enter).
  2. Navigate to HKEY_CURRENT_USER\Console.
  3. Right-click the Console key → New → String Value. Name it CodePage.
  4. Double-click CodePage and set the value to 65001.
Step 2: Use a Unicode-Friendly Font#

Older fonts (e.g., Raster Fonts) don’t support diacritical characters. Switch to a font like Consolas or Lucida Console:

  1. Right-click the CMD title bar → Properties → Font.
  2. Select "Consolas" or "Lucida Console" (ensure "TrueType font" is checked).
  3. Click "OK" to save.

3.2.2 For PowerShell#

PowerShell uses .NET’s OutputEncoding and InputEncoding settings. Configure it to UTF-8:

Step 1: Set OutputEncoding to UTF-8#

Run this command in PowerShell to set the output encoding:

$OutputEncoding = [System.Text.Encoding]::UTF8  

To make this permanent (persist across sessions):

  1. Open your PowerShell profile:
    notepad $PROFILE  
    (If prompted to create a new file, click "Yes.")
  2. Add the line:
    $OutputEncoding = [System.Text.Encoding]::UTF8  
  3. Save and close Notepad. Restart PowerShell for changes to take effect.
Step 2: Enable UTF-8 in PowerShell 7+ (Optional)#

If using PowerShell 7 or later (recommended), enable UTF-8 system-wide via:

Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Nls\CodePage' -Name 'ACP' -Value '65001'  

(Requires admin rights; restart your PC afterward.)

3.3 Ensure Commit Messages Use UTF-8#

Even if git log displays correctly, commit messages stored in non-UTF-8 will still appear garbled. Ensure your editor saves commit messages in UTF-8:

3.3.1 Configure Git’s Default Editor#

If you use git commit without -m, Git opens your default editor (e.g., Notepad, VS Code). Configure it to use UTF-8:

  • For VS Code (recommended):

    git config --global core.editor "code --wait --locale=en-US"  

    Then, in VS Code, ensure UTF-8 is enabled:

    1. Open VS Code → File → Preferences → Settings.
    2. Search for files.encoding and set to utf8.
    3. Search for terminal.integrated.defaultProfile.windows and set to your preferred terminal (e.g., "Command Prompt" or "PowerShell").
  • For Notepad:
    Notepad defaults to ANSI (CP1252) for new files. To save commit messages in UTF-8:

    1. When git commit opens Notepad, type your message.
    2. Go to File → Save As.
    3. Set "Encoding" to "UTF-8" (not "UTF-8 with BOM").

The legacy Command Prompt and PowerShell have limited UTF-8 support. For a smoother experience, use Microsoft’s Windows Terminal (free, pre-installed on Windows 11; downloadable for Windows 10).

Step 1: Install Windows Terminal#

Download from the Microsoft Store or via winget install --id Microsoft.WindowsTerminal.

Step 2: Configure UTF-8 in Settings#

  1. Open Windows Terminal.
  2. Press Ctrl + , to open Settings (or click the dropdown → "Settings").
  3. Under "Profiles," select your default terminal (e.g., "Command Prompt" or "PowerShell").
  4. Scroll to "Encoding" and set it to UTF-8.
  5. Under "Appearance," set the font to "Consolas" or "Cascadia Code" (both support Unicode).
  6. Save settings (Ctrl + S).

Windows Terminal natively supports UTF-8 and Unicode, so git log should display diacritics without extra configuration!

4. Advanced Troubleshooting#

If characters still appear garbled, try these fixes:

4.1 Check System Locale#

Windows uses a "system locale" to set default encoding for non-Unicode apps. Ensure it’s set to a UTF-8-compatible locale:

  1. Open Control Panel → Clock and Region → Region → Administrative → Change system locale.
  2. Check "Beta: Use Unicode UTF-8 for worldwide language support."
  3. Restart your PC.

4.2 Test with a Sample Commit#

Create a test commit with diacritical characters to verify:

git commit --allow-empty -m "Test: Café, naïve, ç, ü, ñ"  
git log --oneline  

If Café appears correctly, the issue is fixed!

4.3 Check for Font Issues#

Some fonts (e.g., Raster Fonts) lack Unicode support. In any terminal, ensure you’re using a TrueType font like Consolas, Cascadia Code, or Lucida Console.

5. Conclusion#

Fixing git log encoding issues in Windows 10 boils down to matching Git’s UTF-8 output with your terminal’s encoding. Follow these key steps:

  1. Enforce UTF-8 in Git with i18n.logOutputEncoding and core.quotepath=false.
  2. Set your terminal (Command Prompt/PowerShell) to use UTF-8 (code page 65001) and a Unicode font.
  3. Use Windows Terminal for the best UTF-8 support.
  4. Ensure commit messages are saved in UTF-8 via your editor.

With these changes, diacritical characters like é, ü, and ñ will display correctly in git log, making your Git workflow smoother—especially in multilingual teams!

6. References#