This error appears when Git expects you to describe a merge but you haven't provided a message
When you run git merge without the -m flag, Git opens a text editor and waits for you to type a message explaining why you're combining two branches. If you close that editor without typing anything, or if your system can't open an editor at all, Git stops and shows you the error "merge but no -m option was given." The merge hasn't happened yet — Git is refusing to proceed until you give it a reason for the merge.
This is a safety feature. Every merge creates a record in your repository's history, and that record needs a message so you and your team can understand later why two branches came together. Without a message, the history becomes confusing.
Key Takeaways
- The error means Git opened an editor for your merge message, but you closed it without typing anything.
- The simplest fix is to run the merge again with git merge branch-name -m "Your message here", which skips the editor entirely.
- If you don't know what editor Git is trying to open, you can set a default one in your Git configuration so the right program launches.
- If you already started a merge and got stuck, you can cancel it with git merge --abort and start over.
The quickest way to fix it: add -m and a message
If you just got this error, the merge hasn't completed. Cancel what you started by typing git merge --abort, then run the merge command again with a message included.
For example, if you're merging a branch called feature-login into your main branch, type:
git merge feature-login -m "Merge login feature into main"
Replace "Merge login feature into main" with a short explanation of what this merge does. The message should be clear enough that someone reading your repository history six months from now understands why these branches came together. Git will complete the merge when ready without opening an editor.
Why Git opens an editor in the first place
When you run git merge branch-name without the -m flag, Git assumes you want to write a longer, more detailed message. It launches your default text editor — usually Vim, Nano, or Notepad depending on your system — and waits for you to type and save.
The problem happens when the editor launches but you don't realize it, or when your system doesn't have a default editor set up. You might close the window thinking nothing happened, or the editor might open in a way you don't recognize. Either way, Git sees an empty message and refuses to proceed.
On Windows, the editor might open in the background. On Mac or Linux, it often opens in the terminal itself, which can be confusing if you've never used Vim or Nano before. If you're not expecting an editor to appear, you might close it without understanding what it's for.
Setting a default editor so you know what to expect
If you want to use the editor approach but keep running into trouble, you can tell Git which editor to use. This way, the same program launches every time, and you'll know what to expect.
To set Nano as your default (Nano is simpler than Vim for beginners):
git config --global core.editor "nano"
To set Vim:
git config --global core.editor "vim"
On Windows, to use Notepad:
git config --global core.editor "notepad"
After you set this, when you run git merge branch-name without -m, the editor you chose will open. Type your message, save the file (in Nano, press Ctrl+O then Enter, then Ctrl+X; in Vim, press Escape then type :wq and press Enter), and the merge will complete.
Understanding what the merge message should say
A merge message doesn't need to be long. A single line is fine. The goal is to explain what you're bringing in and why.
Good examples:
- Merge feature-login into main
- Merge bug-fix-404 (fixes page not found error)
- Merge documentation updates from develop
Bad examples that don't explain anything:
- merge
- asdf
- test
If you're merging a branch that fixes a specific issue or adds a specific feature, mention it. If you're merging from one team branch into another, say which branches. The message is for your future self and your teammates.
If you're stuck in an editor right now
If an editor is open on your screen and you don't know how to proceed, the safest move is to close it without saving. In most editors, you can press Ctrl+C or close the window. Git will see that you didn't provide a message and will show you the error again — which is fine, because then you can use the -m flag method instead.
If you're in Vim specifically and feel trapped, press Escape, then type :q! (colon, the letter q, exclamation mark) and press Enter. This closes Vim without saving anything.
If you're in Nano, press Ctrl+X, then press N when it asks if you want to save. This closes Nano and cancels the merge.
Preventing this error going forward
The easiest approach is to always use -m with your merge commands. It's faster, clearer, and you won't have to deal with editors at all:
git merge branch-name -m "Your message"
If you work on a team, check whether your project has a standard for merge messages. Some teams want "Merge X into Y", others want "Merge X: description of what changed". Following the standard makes your history easier to read.
You can also create a Git alias to make this even faster. If you want git m to mean git merge -m, run:
git config --global alias.m "merge -m"
Then you can type git m branch-name "Your message" and it works the same way.
Frequently Asked Questions
Can I undo a merge that already happened?
Yes. If the merge completed but you want to undo it, run git revert -m 1 HEAD. This creates a new commit that reverses the merge. If you want to erase the merge entirely as if it never happened, run git reset --hard HEAD~1, but only do this if nobody else has pulled your changes yet.
What if I don't remember the exact branch name I'm merging?
Type git branch to see a list of all branches in your repository. The branch with an asterisk next to it is the one you're currently on. Find the branch you want to merge, then use its exact name in your merge command.
Does the -m message have to be one line?
No. You can write multiple lines if you want to explain the merge in detail. Use git merge branch-name -m "Line one" -m "Line two", or use the editor method and type as much as you need. Most teams keep it to one or two lines for readability.
What's the difference between -m and opening an editor?
They do the same thing — both create a merge message. The -m flag just lets you type the message on the command line instead of opening an editor. Use whichever feels more natural to you.