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.
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.
First, verify what encoding settings Git currently uses:
# 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 i18nIf no value is returned for i18n.commitEncoding, Git assumes UTF-8 (which is the recommended default).
Ensure your terminal and text editor are configured to use UTF-8:
Terminal (Linux/macOS):
# 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-8Windows Terminal/PowerShell:
# Set console output encoding to UTF-8
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
chcp 65001VS Code: Open Settings and search for "encoding", then set "Files: Encoding" to "utf8".
Vim: Add to your .vimrc:
set encoding=utf-8
set fileencoding=utf-8If your terminal is already configured for UTF-8, use the -m flag to provide the message directly:
# 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.
If you've already made a commit with the warning and want to fix it:
# 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 --amendMake sure your editor and terminal are configured for UTF-8 before running this command.
If your project specifically requires a non-UTF-8 encoding, tell Git what encoding to use:
# 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-1Supported 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.
If you need to fix historical commits with non-UTF-8 messages, use git filter-branch:
# Convert commit messages from ISO-8859-1 to UTF-8
git filter-branch --msg-filter 'iconv -f ISO-8859-1 -t UTF-8' -- --allWarning: 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.
After fixing, verify your commits are properly encoded:
# 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.
### 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
# 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:
# Set output encoding (defaults to commitEncoding if not set)
git config --global i18n.logOutputEncoding UTF-8Git 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
# 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:
{
"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.
warning: BOM detected in file, this may cause issues
UTF-8 Byte Order Mark (BOM) detected in file
fatal: Server does not support --shallow-exclude
Server does not support --shallow-exclude
warning: filtering out blobs larger than limit
Git partial clone filtering large blobs warning
fatal: Server does not support --shallow-since
Server does not support --shallow-since in Git
kex_exchange_identification: Connection closed by remote host
Connection closed by remote host when connecting to Git server