How to fix warning: commit message does not conform to UTF-8 in Git

GitBEGINNERLOWUpdated Dec 6, 2025ยท 234 views

Git warns that your commit message contains characters not encoded in UTF-8. Fix this by setting the i18n.commitEncoding config or by converting your message to UTF-8 encoding before committing.

Quick fix

Fixes warning: commit message does not conform to UTF-8

# Check commit encoding setting
git config --get i18n.commitEncoding

# Check log output encoding
git config --get i18n.logOutputEncoding

# Show all i18n-related config
git config --list | grep i18n
  1. Check your current commit encoding settings
  2. Configure your terminal and editor for UTF-8
  3. Use the inline message flag with UTF-8 text
  4. Amend a commit with a properly encoded message
git โ€” error
# Check commit encoding setting
git config --get i18n.commitEncoding
# Check log output encoding
git config --get i18n.logOutputEncoding
# Show all i18n-related config
git config --list | grep i18n
warning: commit message does not conform to UTF-8

What this error means

When Git creates a commit, it expects the commit message to be encoded in UTF-8 by default. If Git detects that your commit message contains byte sequences that don't represent valid UTF-8 characters, it displays this warning to alert you that the message may not display correctly on other systems or when viewed through Git tools. UTF-8 is the universal standard for text encoding in modern software development. It can represent virtually any character from any writing system while remaining compatible with ASCII. When a commit message uses a different encoding (such as ISO-8859-1, Windows-1252, or other legacy encodings), the message may appear as garbled text, question marks, or squares when viewed on systems expecting UTF-8. Git deliberately does not force UTF-8 or automatically convert your commit messages because encoding conversion is not always reversible. Instead, it warns you and allows you to either fix the encoding or explicitly declare what encoding you're using via the `i18n.commitEncoding` configuration.

Typical symptoms

  • Warning message appears after running 'git commit': 'commit message does not conform to UTF-8'
  • Commit messages with accented characters, umlauts, or non-ASCII characters display incorrectly in git log
  • Team members on different systems see garbled or corrupted commit messages
  • CI/CD pipelines or Git hosting services (GitHub, GitLab) show corrupted commit message text
  • Characters appear as question marks, squares, or multiple strange symbols instead of the intended text
  • Git log output shows encoding warnings when viewing historical commits

Common causes

  1. Text editor or terminal using a non-UTF-8 encoding (e.g., ISO-8859-1, Windows-1252, or system locale encoding)
  2. Copy-pasting text from documents or websites that use legacy encodings
  3. System locale not configured for UTF-8, causing shell and editor to use a different encoding
  4. Git configured with a different i18n.commitEncoding that doesn't match the actual message encoding
  5. Using a legacy editor or IDE that saves files in a non-UTF-8 encoding by default
  6. Importing commits from an external source (git-svn, patches) with non-UTF-8 messages

How to fix "warning: commit message does not conform to UTF-8"

1Check your current commit encoding settings

First, verify what encoding settings Git currently uses:

bash
# Check commit encoding setting
git config --get i18n.commitEncoding

# Check log output encoding
git config --get i18n.logOutputEncoding

# Show all i18n-related config
git config --list | grep i18n

If no value is returned for i18n.commitEncoding, Git assumes UTF-8 (which is the recommended default).

2Configure your terminal and editor for UTF-8

Ensure your terminal and text editor are configured to use UTF-8:

Terminal (Linux/macOS):

bash
# Check current locale
locale

# Set UTF-8 locale (add to ~/.bashrc or ~/.zshrc)
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8

Windows Terminal/PowerShell:

powershell
# Set console output encoding to UTF-8
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
chcp 65001

VS Code: Open Settings and search for "encoding", then set "Files: Encoding" to "utf8".

Vim: Add to your .vimrc:

vim
set encoding=utf-8
set fileencoding=utf-8
3Use the inline message flag with UTF-8 text

If your terminal is already configured for UTF-8, use the -m flag to provide the message directly:

bash
# Commit with inline UTF-8 message
git commit -m "Fix: Handle umlauts correctly (Umlaute)"

This ensures the message is encoded in whatever encoding your terminal uses. If your terminal is UTF-8, the message will be UTF-8 encoded.

4Amend a commit with a properly encoded message

If you've already made a commit with the warning and want to fix it:

bash
# Amend the last commit with a new message
git commit --amend -m "Your corrected UTF-8 message here"

# Or open the editor to re-type the message
git commit --amend

Make sure your editor and terminal are configured for UTF-8 before running this command.

5Set i18n.commitEncoding for non-UTF-8 projects

If your project specifically requires a non-UTF-8 encoding, tell Git what encoding to use:

bash
# Set encoding for this repository only
git config i18n.commitEncoding ISO-8859-1

# Or set globally for all repositories
git config --global i18n.commitEncoding ISO-8859-1

Supported encodings include:
- ISO-8859-x (Western European, etc.)
- CP125x (Windows code pages)
- Other extended ASCII encodings

Note: UTF-16, UTF-32, EBCDIC, and CJK multi-byte encodings (GBK, Shift-JIS, Big5, EUC-x) are NOT supported for commit messages.

6Convert existing commits to UTF-8

If you need to fix historical commits with non-UTF-8 messages, use git filter-branch:

bash
# Convert commit messages from ISO-8859-1 to UTF-8
git filter-branch --msg-filter 'iconv -f ISO-8859-1 -t UTF-8' -- --all

Warning: This rewrites commit history. Only do this on branches that haven't been shared with others, or coordinate with your team first.

For a safer approach on shared repositories, simply ensure all new commits use UTF-8 going forward.

7Verify the fix

After fixing, verify your commits are properly encoded:

bash
# View the raw commit to check for encoding header
git cat-file -p HEAD

# Check if the commit has an encoding header
git log -1 --format='%H %e'

If the commit message is UTF-8 (the default), no encoding header will be present. If you set a different encoding, you'll see it listed in the commit object.

Advanced notes

### How Git Handles Commit Message Encoding

Git stores commit messages as byte sequences. When i18n.commitEncoding is not set, Git assumes UTF-8 and warns if the bytes don't form valid UTF-8 sequences. When the config is set to a different encoding, Git:

1. Stores the specified encoding in the commit object's encoding header
2. Other Git commands (git log, git show) read this header and attempt to convert to the output encoding

bash
# Example: viewing a commit with encoding header
git cat-file -p <commit-hash>
# Output includes: encoding ISO-8859-1

### Output Encoding Configuration

Control how Git displays commit messages:

bash
# Set output encoding (defaults to commitEncoding if not set)
git config --global i18n.logOutputEncoding UTF-8

Git will attempt to transcode from the commit's encoding to your configured output encoding.

### CI/CD and Remote Repository Considerations

Most Git hosting services (GitHub, GitLab, Bitbucket) and CI systems expect UTF-8. Using non-UTF-8 encodings may cause:

- Garbled text in web interfaces
- Failed webhook payloads due to encoding errors
- Issues with automated tools parsing commit messages

For maximum compatibility, always use UTF-8.

### Detecting Encoding Issues in Existing Repositories

bash
# List commits with non-UTF-8 encoding headers
git log --all --format='%H %e' | grep -v '^[a-f0-9]* $'

# Show commits that might have encoding issues
git log --all --oneline --encoding=UTF-8 2>&1 | head -50

### Editor-Specific Settings

Sublime Text: Add to preferences:

json
{
    "default_encoding": "UTF-8",
    "fallback_encoding": "UTF-8"
}

Notepad++ (Windows): Go to Settings > Preferences > New Document and select "UTF-8" under Encoding.

JetBrains IDEs: Go to Settings > Editor > File Encodings and set all options to UTF-8.

Frequently asked questions

What does "warning: commit message does not conform to UTF-8" mean?
When Git creates a commit, it expects the commit message to be encoded in UTF-8 by default. If Git detects that your commit message contains byte sequences that don't represent valid UTF-8 characters, it displays this warning to alert you that the message may not display correctly on other systems or when viewed through Git tools. UTF-8 is the universal standard for text encoding in modern software development.
How do I fix "warning: commit message does not conform to UTF-8"?
Git warns that your commit message contains characters not encoded in UTF-8. Fix this by setting the i18n.commitEncoding config or by converting your message to UTF-8 encoding before committing.
What causes "warning: commit message does not conform to UTF-8"?
Text editor or terminal using a non-UTF-8 encoding (e.g., ISO-8859-1, Windows-1252, or system locale encoding) Copy-pasting text from documents or websites that use legacy encodings System locale not configured for UTF-8, causing shell and editor to use a different encoding
Is the "warning: commit message does not conform to UTF-8" error serious?
It is a low-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading