3

Sometimes git opens vi and shows me a message like this:

Merge branch 'master' into feature/heal-the-world

# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.

I always close the vi unchanged.

Is there a way to avoid this "vi PopUp"?

I would like to stay with my current workflow, I just want git to automatically do this. I don't want to switch to rebase.

Update

since some calls to git get done in scripts, I need a way to change the default behaviour of git. An alias which does what I need does not help here.

guettli
  • 25,042
  • 81
  • 346
  • 663

2 Answers2

3

one-time setup:

git config --global alias.gm='-c core.editor=true merge'

from then on:

git gm
jthill
  • 55,082
  • 5
  • 77
  • 137
  • I updated the question: since some calls to `git` get done in scripts, I need a way to change the default behaviour of git. An alias which does what I need does not help here. – guettli Jan 04 '18 at 15:15
  • @jthill Do you mean `alias.gm`? – phd Jan 04 '18 at 16:58
3

You can use the --no-edit argument, to accept the auto-generated message.

git merge other_branch --no-edit

Unfortunately, there is no simple solution to make this the default behavior for all branches, as you can see in Configure git mergeoptions --no-edit on all branches. You can either specify this for all branches, or use an alias that will shadow the default merge, like in https://stackoverflow.com/a/44782300/2266261

Dunno
  • 3,632
  • 3
  • 28
  • 43
  • I updated the question: since some calls to `git` get done in scripts, I need a way to change the default behaviour of git. An alias which does what I need does not help here. – guettli Jan 04 '18 at 15:15
  • @guettli in that case, I think https://stackoverflow.com/a/44782300/2266261 is the simplest solution – Dunno Jan 04 '18 at 15:24