问题
I am using Git. I did a pull from a remote repo and got an error message:
"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 Enter but nothing happens.
How do I tell Git/terminal I am done typing in my message?
I am using terminal on OS X.
回答1:
It's not a Git error message, it's the editor as git uses your default editor.
To solve this:
- press "i"
- write your merge message
- press "esc"
- write ":wq"
- then press enter
回答2:
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:
Type some message
CtrlCO
Type the file name (such as "Merge_feature01") and press Enter
CtrlX to exit
Now if you go to .git and you will find the file "Merge_feature01", that's the merge log actually.
回答3:
tl;dr Set the editor to something nicer, like Sublime or Atom
Here nice is used in the meaning of an editor you like or find more user friendly.
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 Vim and try to understand why some people think Vim is the greatest editor in existence, there is a quicker way of fixing this problem :-)
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
- the git config setting
core.editor
(per project, or globally) - the
VISUAL
orEDITOR
environment variable (this works for other programs as well)
I'll cover the first option for a couple of popular editors, but GitHub has an excellent guide on this for many editors as well.
To use Atom
Straight from its docs, enter this in a terminal:
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 --wait
option.
To use Sublime Text
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:
git config --global core.editor "subl -n -w"
回答4:
Just Do,
CTRL + X
CTRL + C
It will ask you to save file, Press Y, then you are done.
回答5:
Instead, you could git CtrlZ and 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.
回答6:
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
回答7:
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 rebase
or git pull --rebase
Here is a good article explaining the difference between git pull
& git pull --rebase
.
https://www.derekgourlay.com/blog/git-when-to-merge-vs-when-to-rebase/
回答8:
How to add a message in android studio terminal with your merge.This is for mac users.
- 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"
You are all done with your merge.Then you can continue working on either pull to your local after or create a new branch.
来源:https://stackoverflow.com/questions/19085807/please-enter-a-commit-message-to-explain-why-this-merge-is-necessary-especially