Why is git prompting me for a post-pull merge commit message?

拥有回忆 提交于 2019-12-17 07:04:34

问题


Recently, following any git pull, git has started spawning my text editor, and asking for a merge commit message. A commit message is already pre-filled, and I just have to save and close the window to complete the pull.

In the past, it would do the merge silently, with a standard commit message (along the lines of Merge branch 'dev' of remote.com:/repo into dev).

I recently updated git to version 1.7.11.3 (via homebrew), but can't think of anything else I might have done to change this behavior. Is this a setting, or is there otherwise some way of getting back to the way it was?


回答1:


In git 1.7.10, the git developers decided merge commits could be made too easily. As explained in this blog post, forcing the interactive commit message behavior should make those commit messages more detailed and could reduce the overall frequency of unnecessary merges.

You can use the --no-edit flag to avoid this behavior, but, well, don't. Merge commits, like any commits to history, should be well constructed. Your history should be nothing but useful.




回答2:


To create a shortcut for future use, either:-

Edit your ~/.gitconfig with the following:

[core]
    mergeoptions = --no-edit

Or execute the following in Terminal

git config --global core.mergeoptions --no-edit




回答3:


First, take heed of the warnings in Christopher's answer above.

Then, if you still want to disable automatic merge commit message editing, set this environment variable:

    GIT_MERGE_AUTOEDIT=no

This environment variable and its "no" setting are documented on the git merge doc page. It is recommended to use it only in scripts that need to merge non-interactively, but of course it can be set as part of your shell environment to make its effects more permanent.



来源:https://stackoverflow.com/questions/11744081/why-is-git-prompting-me-for-a-post-pull-merge-commit-message

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!