The 'Aborting commit due to empty commit message' error occurs when Git's text editor closes without saving a commit message, or when the message file is empty. This typically happens when the configured editor doesn't wait for user input or exits prematurely.
When you run `git commit` without the `-m` flag, Git opens a text editor for you to write a commit message. If Git receives an empty message (or one containing only comments starting with #), it aborts the commit to prevent creating commits without meaningful descriptions. This error is most commonly caused by editor configuration issues where the text editor opens in a separate window but doesn't make Git wait for you to finish writing the message. When the editor starts as a background process, Git immediately reads the (still empty) commit message file and aborts. The error can also occur when you intentionally leave the commit message empty to cancel a commit, when there are file permission issues preventing Git from reading the message file, or when using GUI-based editors that require specific command-line flags to work properly with Git.
The most common fix is adding the appropriate 'wait' flag for your editor. This tells the editor to make Git wait until you close the file:
# For VS Code
git config --global core.editor "code --wait"
# For Sublime Text
git config --global core.editor "subl --wait"
# For Atom
git config --global core.editor "atom --wait"
# For MacVim
git config --global core.editor "mvim -f"
# For Kate (KDE)
git config --global core.editor "kate --block"
# For Notepad++ (Windows)
git config --global core.editor "'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin"
# For nano (terminal-based, already waits by default)
git config --global core.editor "nano"
# For vim (terminal-based, already waits by default)
git config --global core.editor "vim"Multiple editor configurations at different levels can conflict. Check all of them:
# Show all editor configurations and their sources
git config --list --show-origin | grep -i editor
# Check each level specifically
git config --global core.editor # User-level
git config --local core.editor # Repository-level
git config --system core.editor # System-levelIf you see conflicting values, remove the unwanted ones:
# Remove repository-level setting
git config --local --unset core.editor
# Remove global-level setting
git config --global --unset core.editorThen set the correct one with the wait flag.
If you need to make a commit quickly while troubleshooting, use the -m flag to provide the message directly:
# Single-line commit message
git commit -m "Your commit message here"
# Multi-line commit message
git commit -m "Short summary" -m "Longer description on second line"This bypasses the editor entirely.
Verify that Git properly waits for your editor:
# Test the editor configuration
GIT_EDITOR="code --wait" git commit --allow-empty
# Or test with your configured editor
git commit --allow-emptyThe editor should open and Git should display "Waiting for your editor to close the file..." (or similar). Once you save and close the editor, Git should proceed with the commit or abort if you left it empty.
If GUI editors continue to cause problems, consider using a terminal-based editor that runs in the same process as Git:
# Use vim (pre-installed on most systems)
git config --global core.editor "vim"
# Use nano (simpler interface)
git config --global core.editor "nano"
# Use vi (available on virtually all Unix systems)
git config --global core.editor "vi"Terminal editors run in the foreground by default and don't have the waiting/synchronization issues that GUI editors have.
If you're using VS Code and the commit still fails, an extension might be causing the editor to crash or return early:
# Try with extensions disabled
git config --global core.editor "code --disable-extensions --wait"If this works, re-enable extensions one by one to find the problematic one. Common culprits include extensions that auto-format on save or modify file behavior.
Git ignores lines starting with # in commit messages (they're treated as comments). If your entire message consists of such lines, Git considers it empty.
When the editor opens, you'll see something like:
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.Make sure to write your message above these comment lines without a # prefix. If you want to include # in your message, you can change the comment character:
# Use a different comment character
git config --global core.commentChar ";"### Windows-Specific Issues
On Windows, file paths with spaces can cause issues. Always quote the full path to your editor:
# Windows with VS Code
git config --global core.editor "'C:/Users/YourName/AppData/Local/Programs/Microsoft VS Code/Code.exe' --wait"
# Windows with Notepad++
git config --global core.editor "'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin"Additionally, if you're working on files under C:\Program Files, Windows may block the creation of temporary files, causing the commit message file to fail.
### Environment Variable Alternative
Instead of using git config, you can set the GIT_EDITOR or EDITOR environment variable:
# In your shell profile (.bashrc, .zshrc, etc.)
export GIT_EDITOR="code --wait"
# or
export EDITOR="code --wait"Git checks these in order: GIT_EDITOR > core.editor config > EDITOR environment variable.
### Interactive Rebase and Merge Commits
This error can also appear during interactive operations:
# Interactive rebase
git rebase -i HEAD~3
# Commit after conflict resolution
git commitThe same editor configuration fix applies. If you need to abort an interactive rebase that's stuck:
git rebase --abort### Commit Message Templates
If you use commit templates, ensure the template file exists and is readable:
# Check your template configuration
git config --global commit.template
# Verify the file exists
cat $(git config --global commit.template)A missing or unreadable template can cause editor issues.
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