Coding⏱️ 2 min read📅 2026-05-31

How to Fix: Git error on commit after merge - fatal: cannot do a partial commit during a merge

Git error on commit after merge - fatal: cannot do a partial commit during a merge

Quick Answer: Try using `git add file.php` followed by `git commit --amend -m "message"` to make a single-file commit.

The error 'fatal: cannot do a partial commit during a merge' occurs when you try to commit files after merging changes from another repository. This is because Git expects a full commit, not just individual files.

🔧 Proven Troubleshooting Steps

Method 1: Use `git add` and commit individually

  1. Step 1: Run `git status` to identify the files that are out of sync.

Method 2: Use `git add -p` and edit the diff

  1. Step 1: Run `git add -p file.php` to open an interactive diff editor.

🎯 Final Words

To avoid partial commits, always use `git add` and commit individually or use `git add -p` to edit the diff. This ensures a full commit that includes all changes.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions