为什么 git 提示我输入拉取后合并提交消息?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11744081/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 14:16:30  来源:igfitidea点击:

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

gitgit-pull

提问by shanebonham

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.

最近,在 any 之后git pull,git 开始生成我的文本编辑器,并要求提供合并提交消息。提交消息已经预先填充,我只需要保存并关闭窗口即可完成拉取。

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).

过去,它会默默地进行合并,并带有标准的提交消息(沿着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?

我最近将 git 更新到 1.7.11.3 版(通过自制软件),但想不出我可能会做些什么来改变这种行为。这是一个设置,还是有其他方法可以恢复到原来的状态?

回答by Christopher

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.

在 git 1.7.10 中,git 开发人员认为合并提交太容易了。正如这篇博文中所解释的,强制交互式提交消息行为应该使这些提交消息更加详细,并且可以减少不必要合并的总体频率。

You can use the --no-editflag 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.

您可以使用该--no-edit标志来避免这种行为,但不要这样做。合并提交,就像任何对历史的提交一样,应该很好地构建。你的历史应该只是有用的。

回答by Dallas Clark

To create a shortcut for future use, either:-

要创建供将来使用的快捷方式,请执行以下任一操作:-

Edit your ~/.gitconfigwith the following:

~/.gitconfig使用以下内容编辑您的:

[core]
    mergeoptions = --no-edit

Or execute the following in Terminal

或者在终端中执行以下操作

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

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

回答by emackey

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 mergedoc 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.

这个环境变量及其“no”设置记录在git mergedoc 页面上。建议仅在需要非交互式合并的脚本中使用它,但当然可以将其设置为您的 shell 环境的一部分,以使其效果更持久。