How to fix Aborting commit due to empty commit message in Git

GitBEGINNERLOWUpdated Dec 6, 2025ยท 291 views

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.

Quick fix

Fixes Aborting commit due to empty commit message

# 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"
  1. Configure your editor with the wait flag
  2. Check for conflicting editor configurations
  3. Use the inline message flag as a workaround
  4. Test your editor configuration
git โ€” error
# 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"
Aborting commit due to empty commit message

What this error means

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.

Typical symptoms

  • Git commit immediately fails with 'Aborting commit due to empty commit message'
  • Editor opens briefly then closes, or opens in a separate window while Git proceeds
  • Git does not wait for you to type or save the commit message
  • Commits only work when using 'git commit -m' with an inline message
  • The error appears immediately after running 'git commit' without any time to write a message
  • Interactive rebase or merge commits fail with the same error

Common causes

  1. Editor not configured with 'wait' flag, causing Git to proceed before message is saved
  2. Editor opens in a separate process/window and Git doesn't wait for it to close
  3. Previous editor configuration without proper flags conflicts with new settings
  4. Commit message file contains only lines starting with # (treated as comments)
  5. File permission issues preventing Git from reading the temporary commit message file
  6. Editor crashes or fails to start, returning immediately with empty output
  7. VS Code or other GUI editor extensions causing the editor to return prematurely

How to fix "Aborting commit due to empty commit message"

1Configure your editor with the wait flag

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:

bash
# 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"
2Check for conflicting editor configurations

Multiple editor configurations at different levels can conflict. Check all of them:

bash
# 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-level

If you see conflicting values, remove the unwanted ones:

bash
# Remove repository-level setting
git config --local --unset core.editor

# Remove global-level setting
git config --global --unset core.editor

Then set the correct one with the wait flag.

3Use the inline message flag as a workaround

If you need to make a commit quickly while troubleshooting, use the -m flag to provide the message directly:

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

4Test your editor configuration

Verify that Git properly waits for your editor:

bash
# Test the editor configuration
GIT_EDITOR="code --wait" git commit --allow-empty

# Or test with your configured editor
git commit --allow-empty

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

5Switch to a terminal-based editor

If GUI editors continue to cause problems, consider using a terminal-based editor that runs in the same process as Git:

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

6Check for VS Code extension issues

If you're using VS Code and the commit still fails, an extension might be causing the editor to crash or return early:

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

7Ensure commit message is not just comments

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:

text
# 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:

bash
# Use a different comment character
git config --global core.commentChar ";"

Advanced notes

### Windows-Specific Issues

On Windows, file paths with spaces can cause issues. Always quote the full path to your editor:

bash
# 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:

bash
# 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:

bash
# Interactive rebase
git rebase -i HEAD~3

# Commit after conflict resolution
git commit

The same editor configuration fix applies. If you need to abort an interactive rebase that's stuck:

bash
git rebase --abort

### Commit Message Templates

If you use commit templates, ensure the template file exists and is readable:

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

Frequently asked questions

What does "Aborting commit due to empty commit message" mean?
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.
How do I fix "Aborting commit due to empty commit message"?
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.
What causes "Aborting commit due to empty commit message"?
Editor not configured with 'wait' flag, causing Git to proceed before message is saved Editor opens in a separate process/window and Git doesn't wait for it to close Previous editor configuration without proper flags conflicts with new settings
Is the "Aborting commit due to empty commit message" error serious?
It is a low-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading