13

I'm working on a script that goes through a number of git operations. There was a git merge failure. On the merge operation, I provided the text message with -m. If, after taking care of the conflicts, I run git merge --continue, I get to see an editor and I'm able to see the lines that I used on the first merge operation so that I can edit them. Now, what I want to do is run git merge --continue but I also want git to allow the message that I used originally for the revision. If I tried with git merge --continue --no-edit it fails miserably:

$ git merge --continue --no-edit
fatal: --continue expects no arguments

usage: git merge [<options>] [<commit>...]
   or: git merge --abort
   or: git merge --continue
.
.
.

I then tried setting the message again:

$ git merge --continue -m "BLAH"
fatal: --continue expects no arguments

usage: git merge [<options>] [<commit>...]
   or: git merge --abort
   or: git merge --continue
.
.
.

So, how can I run git merge --continue skipping the text editor altogether and accepting the original comment?

2
  • 4
    Either cheat (run git commit instead of git merge --continue), or cheat (set the editor to a does-nothing-and-succeeds command, e.g., GIT_EDITOR=true git merge --continue). Commented Jun 29, 2019 at 3:35
  • Right.... was able to pull it off with -c core.editor. Were you waiting for me to post the question? :-D Commented Jun 29, 2019 at 3:36

2 Answers 2

14

After a few attempts I was able to do it by setting core.editor to /bin/true:

git -c core.editor=/bin/true merge --continue

Should also work like this:

GIT_EDITOR=/bin/true git merge --continue
Sign up to request clarification or add additional context in comments.

2 Comments

Works also for rebase. May be shortened: git -c core.editor=true rebase --continue
Only the second form worked for me. "-c core.editor=/bin/true" did not show any argument errors, so it seems to have parsed correctly. But it still popped up an interactive editor.
7

As Junio Hamano says in his first reply to this thread, the recommended way to achieve this is to run git commit --no-edit at that point (instead of git merge --continue):

The way to finish a conflicted merge has always been to run "git commit" before "merge --continue" was added, and it still is not just accepted but is the right way to finish a conflicted merge.

...

In fact, "merge --continue --no-edit" is much longer to type than "commit --no-edit".

1 Comment

In case you don't recognize the name and need to look it up (like I did), Junio Hamano is the maintainer of git.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.