如何删除 git 的 MERGE_MSG?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13571849/
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-19 07:48:24  来源:igfitidea点击:

How do I remove git's MERGE_MSG?

gitmergegit-pull

提问by Trip

I've tried a few things suggested, but nothing seems to remove it. This started occurring when I upgraded to Mountain Lion OS X. Anytime I do a git pull, it displays this annoying as heck empty editor with the title MERGE_MSG.

我已经尝试了一些建议的东西,但似乎没有任何东西可以删除它。这在我升级到 Mountain Lion OS X 时开始发生。每当我git pull执行 .

How do I prevent that from popping up globallyacross all my apps?

如何防止它在我的所有应用程序中全局弹出?

回答by Brian Campbell

You can either pass --no-editto git pull, or you can set the environment variable GIT_MERGE_AUTOEDITto no.

您可以传递--no-editgit pull,也可以将环境变量设置GIT_MERGE_AUTOEDITno

From the git pulldocumentation:

git pull文档:

   --edit, --no-edit
       Invoke an editor before committing successful mechanical merge to
       further edit the auto-generated merge message, so that the user can
       explain and justify the merge. The --no-edit option can be used to
       accept the auto-generated message (this is generally discouraged).
       The --edit option is still useful if you are giving a draft message
       with the -m option from the command line and want to edit it in the
       editor.

       Older scripts may depend on the historical behaviour of not
       allowing the user to edit the merge log message. They will see an
       editor opened when they run git merge. To make it easier to adjust
       such scripts to the updated behaviour, the environment variable
       GIT_MERGE_AUTOEDIT can be set to no at the beginning of them.

回答by Robert Siemer

A git pullis a git fetchfollowed by a git merge. – The merge, if it results in a merge commit, asks for that message.

Agit pull是 agit fetch后跟 a git merge。– 合并,如果它导致合并提交,则要求提供该消息。

I would propose to do a git rebaseinstead of a merge. It helps to keep the history linear and it avoids additional merge commits. A git pull --rebasedoes this in one go (i.e. it is git fetchfollowed by a git rebase).

我建议做一个git rebase而不是合并。它有助于保持历史线性并避免额外的合并提交。Agit pull --rebase一次性完成此操作(即git fetch其后跟 a git rebase)。

回答by Pavlonator

merge of remote branch to local gives more control then pull. the merge can be 'fast forward' (merge message is not needed), the merge message can be meaningful. Pull does not give you 'fast forward' option and always generate default merge message which is discouraged.

将远程分支合并到本地可以提供更多控制然后拉。合并可以是“快进”(不需要合并消息),合并消息可以是有意义的。拉不给你“快进”选项,总是生成默认的合并消息,这是不鼓励的。