git 请输入提交消息以解释为什么需要进行此合并,尤其是将更新的上游合并到主题分支时

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

Please enter a commit message to explain why this merge is necessary, especially if it merges an updated upstream into a topic branch

gitmacosgit-mergegit-commitgit-commands

提问by bernie2436

I am using Git. I did a pull from a remote repo and got an error message:

我正在使用 Git。我从远程仓库中拉取并收到一条错误消息:

Please enter a commit message to explain why this merge is necessary,
especially if it merges an updated upstream into a topic branch.

请输入提交消息以解释为什么需要进行此合并,
尤其是将更新的上游合并到主题分支时。

I try to type a message and press Enterbut nothing happens.

我尝试输入消息并按,Enter但没有任何反应。

How do I tell Git/Terminal I am done typing in my message?

我如何告诉 Git/终端我已经完成了我的消息输入?

I am using Terminal on OS X.

我在 OS X 上使用终端。

回答by Saad.elzwawy

It's not a Git error message, it's the editor as git uses your default editor.

这不是 Git 错误消息,而是编辑器,因为 git 使用您的默认编辑器。

To solve this:

要解决这个问题:

  1. press "i" (i for insert)
  2. write your merge message
  3. press "esc" (escape)
  4. write ":wq" (write & quit)
  5. then press enter
  1. 按“i”(i 为插入)
  2. 编写您的合并消息
  3. 按“esc”(退出)
  4. 写 ":wq" (写 & 退出)
  5. 然后按回车

回答by xiaohu Wang

Actually it's not an error! It means you should enter some message to mark this merge. My OS is Ubuntu 14.04.If you use the same OS, you just need to do this as follows:

其实这不是错误!这意味着您应该输入一些消息来标记此合并。我的操作系统是 Ubuntu 14.04。如果你使用相同的操作系统,你只需要执行以下操作:

  1. Type some message

  2. CtrlCO

  3. Type the file name (such as "Merge_feature01") and press Enter

  4. CtrlXto exit

  1. 输入一些消息

  2. CtrlCO

  3. 输入文件名(例如“Merge_feature01”)并按 Enter

  4. CtrlX退出

Now if you go to .git and you will find the file "Merge_feature01", that's the merge log actually.

现在如果你去 .git 并且你会发现文件“Merge_feature01”,那实际上是合并日志。

回答by oligofren

tl;dr Set the editor to something nicer, like Sublime or Atom

tl;dr 将编辑器设置为更好的东西,例如 Sublime 或 Atom

Here niceis used in the meaning of an editor you like or find more user friendly.

这里nice用于表示您喜欢的编辑器或对用户更友好的编辑器。

The underlying problem is that Git by default uses an editor that is too unintuitive to use for most people: Vim. Now, don't get me wrong, I love Vim, and while you could set some time aside (like a month) to learn Vimand try to understand why some people think Vim is the greatest editor in existence, there is a quicker way of fixing this problem :-)

潜在的问题是 Git 默认使用一个对大多数人来说太不直观的编辑器:Vim。现在,不要误会我的意思,我喜欢 Vim,虽然你可以留出一些时间(比如一个月)来学习 Vim并尝试理解为什么有些人认为 Vim 是现存最伟大的编辑器,但有一个更快的方法解决这个问题:-)

The fix is not to memorize cryptic commands, like in the accepted answer, but configuring Git to use an editor that you like and understand! It's really as simple as configuring either of these options

解决方法不是像接受的答案那样记住神秘的命令,而是将 Git 配置为使用您喜欢和理解的编辑器!这真的就像配置这些选项中的任何一个一样简单

  1. the git config setting core.editor(per project, or globally)
  2. the VISUALor EDITORenvironment variable (this works for other programs as well)
  1. git config 设置core.editor(每个项目,或全局)
  2. VISUALEDITOR环境变量(此作品为其他程序以及)

I'll cover the first option for a couple of popular editors, but GitHub has an excellent guide on this for many editorsas well.

我将介绍几个流行编辑器的第一个选项,但 GitHub 也为许多编辑器提供了一个很好的指南

To use Atom

使用原子

Straight from its docs, enter this in a terminal: git config --global core.editor "atom --wait"

直接从它的 docs,在终端中输入: git config --global core.editor "atom --wait"

Git normally wait for the editor command to finish, but since Atom forks to a background process immediately, this won't work, unless you give it the --waitoption.

Git 通常会等待编辑器命令完成,但由于 Atom 会立即派生到后台进程,因此这将不起作用,除非您为其提供--wait选项。

To use Sublime Text

使用 Sublime 文本

For the same reasons as in the Atom case, you need a special flag to signal to the process that it shouldn't fork to the background:

出于与 Atom 情况相同的原因,您需要一个特殊的标志来通知进程它不应该分叉到后台:

git config --global core.editor "subl -n -w"

git config --global core.editor "subl -n -w"

回答by Mandeep Singh

Just Do,

做就是了,

CTRL+ X

CTRL+ X

CTRL+ C

CTRL+ C

It will ask you to save file, Press Y, then you are done.

它会要求您保存文件,按Y,然后您就完成了。

回答by Vivek Singh

Here its asking you for a message which connect with your merge for future reference why you done this merge.

在这里,它要求您提供一条与您的合并相关的消息,以供将来参考您为何进行此合并。

press "i"
on top above on #lines write your message
press "esc" button
write ":wq" (it will write in bottom automatically)
press enter

回答by hgrov52

Instead, you could git CtrlZand retry the commit but this time add " -m " with a message in quotes after it, then it will commit without prompting you with that page.

相反,您可以 git 并重CtrlZ试提交,但这次添加“ -m ”并在其后加上引号中的消息,然后它将提交而不提示您使用该页面。

回答by Ankush Jain

Since your local repository is few commits ahead, git tries to merge your remote to your local repo. This can be handled via merge, but in your case, perhaps you are looking for rebase, i.e. add your commit to the top. You can do this with

由于您的本地存储库提前提交很少,因此 git 会尝试将您的远程存储库合并到您的本地存储库。这可以通过合并处理,但在您的情况下,也许您正在寻找变基,即将您的提交添加到顶部。你可以这样做

git rebaseor git pull --rebase

git rebase或者 git pull --rebase

Here is a good article explaining the difference between git pull& git pull --rebase.

这是一篇很好的文章,解释了git pull&之间的区别git pull --rebase

https://www.derekgourlay.com/blog/git-when-to-merge-vs-when-to-rebase/

https://www.derekgourlay.com/blog/git-when-to-merge-vs-when-to-rebase/

回答by NelsonRoberts

How to add a message in android studio terminal with your merge.This is for mac users.

如何使用合并在 android studio 终端中添加消息。这是针对 mac 用户的。

  • Step one - Press "i"
  • Step two - Enter you message after "#"
  • Step three- Press "esc"
  • Step four- at the very bottom write ":wq"
  • Step five- Press "Enter"
  • 第一步 - 按“i”
  • 第二步 - 在“#”后输入您的信息
  • 第三步 - 按“esc”
  • 第四步 - 在最底部写“:wq”
  • 第五步 - 按“Enter”

You are all done with your merge.Then you can continue working on either pull to your local after or create a new branch.

你已经完成了你的合并。然后你可以继续工作,要么拉到你的本地,要么创建一个新的分支。

回答by Vipin Kumar Shakya

It's not a Git error message, it's the editor git uses your default editor.

这不是 Git 错误消息,而是编辑器 git 使用您的默认编辑器。

To solve this:

要解决这个问题:

  1. press “i”
  2. write your merge message
  3. press “esc”
  4. write “:wq”
  5. and press enter
  1. 按“我”
  2. 编写您的合并消息
  3. 按“esc”
  4. 写“:wq”
  5. 然后按回车

Explanation

解释

The way you remember this is that “i” is for “insert”, “esc” is the exit the insertion, and “:wq” is just “write” and “quit”.

你记住的方式是“i”是“插入”,“esc”是插入的退出,而“:wq”只是“写”和“退出”。

回答by ehsan asarzadeh

this is not an error. you have to add a massege for this merge

这不是错误。您必须为此合并添加按摩

to solve this:

解决这个问题:

  1. press "i" to insert your massege
  2. write your massege
  3. press "esc"
  4. write ":wq" (write and quit for saving the massege and exit)
  5. press "enter"
  1. 按“i”插入按摩
  2. 写你的按摩
  3. 按“esc”
  4. write ":wq"(写入并退出以保存按摩并退出)
  5. 按“输入”