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.

2 Answers 2

4

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

Sign up to request clarification or add additional context in comments.

2 Comments

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 in that case, I think stackoverflow.com/a/44782300/2266261 is the simplest solution
3

one-time setup:

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

from then on:

git gm 

2 Comments

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.
@jthill Do you mean alias.gm?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.