使用 pull 命令时,github 锁定 Mac 终端

我正在 Mac (命令行)上学习 github,每次学习 git pull origin master我都会得到这个

# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
".git/MERGE_MSG" 7L, 293C

终端似乎锁定,不允许我立即输入任何东西,然后当它最终允许我输入文本,它似乎不识别 git 命令。

这是 Git 的漏洞,还是我遗漏了什么?

60156 次浏览

You're in the text editor, vim! It's a modal text editor, so you would need to:

  1. Press i to enter insert mode.
  2. Now you can type your message, as if you were in a normal (non-modal) text editor.
  3. Press esc to go back to command mode.
  4. Then type :w followed by enter to save.
  5. Finally :q followed by enter to quit.

Make it simple.

Type :wq and enter

I fixed this problem by executing following steps

  1. Remove #MERGE_MSG#

    rm .git/\#MERGE_MSG#

  2. Remove MERGE_HEAD

    rm .git/MERGE_HEAD

Additionally, I explicitly set git's editor to an editor that I am familiar with vim (you can set nano)

`git config --global core.editor "vim"`

Run this command

git config --global core.editor "gedit"

Add your message in this file and save it. Go back pull now.

The editor looks like to be vim according to your descriptions. This console is simply telling you to write some message for the commit you want to make, and it is compulsory as it does.

  • Just type i and you'll go in the -- INTER -- mode, now you can write your comments.

  • After you have done writing, press esc key in your keyboard and you'll go to command mode. (see on the bottom of the console)

  • Now save changes by writing :w followed by pressing enter key

Writing <code>:w</code> command

  • You can quit now by writing :q followed by pressing enter key

Writing <code>:q</code> command

  • Hurray! Finally you're back to the main console.

You can do git checkout --merge yourbranch

A three-way merge between the current branch, your working tree contents, and the new branch is done, and you will be on the new branch.

Problems usually happen when we misspell something.
It is more likely this command you are interested in:

git commit -m "message"

if there was a problem, it might say something like

Your branch and 'origin/master' have diverged,
and have 2 and 1 different commits each, respectively.
(use "git pull" to merge the remote branch into yours)

and use:

git pull

which should lead to:

Already up-to-date.

Then it is good to check:

git status

and try pushing again:

git push

More simple is first ESC and then : x (lowercase).