buzzedword
buzzedword

Reputation: 3168

How to automate git merge to not prompt to confirm the commit message?

I'm trying to do some automation scripts using git, simple things like updating submodules, moving to proper tags etc, but one of the problems I'm now finding is that git now forces you to confirm a merge message. Is there any way to squelch this behavior from happening?

Upvotes: 52

Views: 16229

Answers (5)

MindSwipe
MindSwipe

Reputation: 7855

Note that all the answers given work, but none has fixed my specific use-case. Specifically, my use case is doing a git merge --continue after fixing conflicts and don't want to edit my environment variables (as sometimes I want the editor to show, and sometimes don't). So, after a little Googling I found that I can pass -c core.editor=true to the command to make git not open an editor, that makes the command:

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

Upvotes: 0

Liam Nguyen
Liam Nguyen

Reputation: 163

Use this command:

git merge other_branch --commit --no-edit

--commit to do commit automatically right after the merge.

--no-edit to prevent showing up the commit message editor.

Upvotes: 14

kenorb
kenorb

Reputation: 166379

You can change the editor to not show it up by replacing vim with cat or true, e.g.:

GIT_EDITOR=true git merge branch_name

This will populate the merge message automatically.

Upvotes: 1

ola
ola

Reputation: 478

To prevent git from promting you for an commit message on mac add this to your .bashrc or .bash_profile (read more about the difference between the two files)

export GIT_MERGE_AUTOEDIT=no

Then in your terminal type:

source ~/.bashrc

to reload your bash-file and continue without any interference.

Upvotes: 28

ziad-saab
ziad-saab

Reputation: 20239

You can add the --no-edit switch to git-merge and it will not ask you to confirm the merge message.

Upvotes: 82

Related Questions