你尚未完成合并(存在MERGE_HEAD)。

1701

我创建了一个名为“f”的分支,并在主分支上进行了检出。 当我尝试使用git pull命令时,我收到了以下消息:

You have not concluded your merge (MERGE_HEAD exists).
Please, commit your changes before you can merge.

当我尝试执行git status时,它给出了以下结果:

On branch master
# Your branch and 'origin/master' have diverged,
# and have 1 and 13 different commit(s) each, respectively.
#
# Changes to be committed:
#
#   modified:   app/assets/images/backward.png
#   modified:   app/assets/images/forward.png
#   new file:   app/assets/images/index_background.jpg
#   new file:   app/assets/images/loading.gif
#   modified:   app/assets/images/pause.png
#   modified:   app/assets/images/play.png
#   new file:   app/assets/javascripts/jquery-ui-bootstrap.js
#   new file:   app/assets/stylesheets/jquery-ui-bootstrap.css
#   modified:   app/controllers/friends_controller.rb
#   modified:   app/controllers/plays_controller.rb
#   modified:   app/mailers/invite_friends_mailer.rb
#   modified:   app/mailers/send_plays_mailer.rb
#   modified:   app/mailers/shot_chart_mailer.rb
#   modified:   app/views/friends/show_plays.html.erb
#   modified:   app/views/layouts/application.html.erb
#   modified:   app/views/plays/_inbox_table.html.erb
#   modified:   app/views/plays/show.html.erb
#   modified:   app/views/welcome/contact_form.html.erb
#   modified:   app/views/welcome/index.html.erb
#   modified:   log/development.log
#   modified:   log/restclient.log
#   new file:   tmp/cache/assets/C1A/C00/sprockets%2Fb7901e0813446f810e560158a1a97066
#   modified:   tmp/cache/assets/C64/930/sprockets%2F65aa1510292214f4fd1342280d521e4c
#   new file:   tmp/cache/assets/C73/C40/sprockets%2F96912377b93498914dd04bc69fa98585
#   new file:   tmp/cache/assets/CA9/090/sprockets%2Fa71992733a432421e67e03ff1bd441d8
#   new file:   tmp/cache/assets/CCD/7E0/sprockets%2F47125c2ebd0e8b29b6511b7b961152a1
#   modified:   tmp/cache/assets/CD5/DD0/sprockets%2F59d317902de6e0f68689899259caff26
#   modified:   tmp/cache/assets/CE3/080/sprockets%2F5c3b516e854760f14eda2395c4ff2581
#   new file:   tmp/cache/assets/CED/B20/sprockets%2F423772fde44ab6f6f861639ee71444c4
#   new file:   tmp/cache/assets/D0C/E10/sprockets%2F8d1f4b30c6be13017565fe1b697156ce
#   new file:   tmp/cache/assets/D12/290/sprockets%2F93ae21f3cdd5e24444ae4651913fd875
#   new file:   tmp/cache/assets/D13/FC0/sprockets%2F57aad34b9d3c9e225205237dac9b1999
#   new file:   tmp/cache/assets/D1D/DE0/sprockets%2F5840ff4283f6545f472be8e10ce67bb8
#   new file:   tmp/cache/assets/D23/BD0/sprockets%2F439d5dedcc8c54560881edb9f0456819
#   new file:   tmp/cache/assets/D24/570/sprockets%2Fb449db428fc674796e18b7a419924afe
#   new file:   tmp/cache/assets/D28/480/sprockets%2F9aeec798a04544e478806ffe57e66a51
#   new file:   tmp/cache/assets/D3A/ED0/sprockets%2Fcd959cbf710b366c145747eb3c062bb4
#   new file:   tmp/cache/assets/D3C/060/sprockets%2F363ac7c9208d3bb5d7047f11c159d7ce
#   new file:   tmp/cache/assets/D48/D00/sprockets%2Fe23c97b8996e7b5567a3080c285aaccb
#   new file:   tmp/cache/assets/D6A/900/sprockets%2Fa5cece9476b21aa4d5f46911ca96c450
#   new file:   tmp/cache/assets/D6C/510/sprockets%2Fb086a020de3c258cb1c67dfc9c67d546
#   new file:   tmp/cache/assets/D70/F30/sprockets%2Facf9a6348722adf1ee7abbb695603078
#   new file:   tmp/cache/assets/DA3/4A0/sprockets%2F69c26d0a9ca8ce383e20897cefe05aa4
#   new file:   tmp/cache/assets/DA7/2F0/sprockets%2F61da396fb86c5ecd844a2d83ac759b4b
#   new file:   tmp/cache/assets/DB9/C80/sprockets%2F876fbfb9685b2b8ea476fa3c67ae498b
#   new file:   tmp/cache/assets/DBD/7A0/sprockets%2F3640ea84a1dfaf6f91a01d1d6fbe223d
#   new file:   tmp/cache/assets/DC1/8D0/sprockets%2Fe5ee1f1cfba2144ec00b1dcd6773e691
#   new file:   tmp/cache/assets/DCC/E60/sprockets%2Fd6a95f601456c93ff9a1bb70dea3dfc0
#   new file:   tmp/cache/assets/DF1/130/sprockets%2Fcda4825bb42c91e2d1f1ea7b2b958bda
#   new file:   tmp/cache/assets/E23/DE0/sprockets%2Fb1acc25c28cd1fabafbec99d169163d3
#   new file:   tmp/cache/assets/E23/FD0/sprockets%2Fea3dbcd1f341008ef8be67b1ccc5a9c5
#   modified:   tmp/cache/assets/E4E/AD0/sprockets%2Fb930f45cfe7c6a8d0efcada3013cc4bc
#   new file:   tmp/cache/assets/E63/7D0/sprockets%2F77de495a665c3ebcb47befecd07baae6
#   modified:   tmp/pids/server.pid
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   Coachbase/
#   log/development.log.orig
#   log/restclient.log.orig

我该怎么办?


2
我的问题是,在解决冲突后,没有任何更改需要提交,所以我不得不像这里建议的那样使用 git commit --no-edit - Gangula
24个回答

10

使用添加标志进行Git提交解决了我的问题:

$ git commit -am "commit message"

6

尝试更改任何临时文件,例如只需删除任何空格或添加空格,然后提交并推送该文件。

git add 'temporary_change_file'

git commit -m "解决git问题"

git push origin develop

然后尝试使用git pull命令:

git pull origin develop

希望这可以帮助您。


这是唯一解决我的问题的方法。谢谢! - PeachesToad

6

我在提交时出现了两个相同消息的提交问题。解决方法如下:

git add.
git commit -m "New commit message"

6

运行git status,它会告诉你要做什么。

例如,在我的情况下,显示的消息是: 所有冲突已解决,但您仍在合并中。(使用“git commit”来完成合并)

确实,运行git commit解决了这个问题。


5
在我的情况下,我进行了一次挑选(cherry pick),但导致了许多合并冲突,因此我决定不完成挑选,放弃所有更改。这样做使我处于一个状态,收到以下错误信息:
“您尚未结束合并(存在MERGE_HEAD)”
为了解决这个问题,我执行了以下git命令来修复它。
git cherry-pick --abort

4

我们可以使用git版本2.12及以上的git merge --continue命令,在解决合并冲突后继续合并。详见此答案


这是目前我认为最好的答案。 - Loolooii

4

引用块

如果你想从另一个分支合并到你的分支,出现这个错误。

首先,你应该尝试进行git commit,然后将另一个分支合并到你的分支中。

  1. "git add . "
  2. git commit
  3. 然后从所需分支执行git pull。

3
最好的方法是撤销合并,然后再次执行合并。通常情况下,您会弄乱事情的顺序。尝试解决冲突并使自己不混乱。
因此,请撤消操作并重新合并。
确保您已为您的环境设置了适当的差异工具。我使用DIFFMERGE在Mac上。我认为DIFFMERGE适用于所有环境。说明在这里:在MAC上安装DIFF Merge 我发现这个链接对解决我的冲突很有帮助:Git基本合并冲突

2

首先,在继续之前,请确保没有冲突。

检查您的.git文件夹中是否没有*文件。

我知道没有冲突,但不知怎么会有两个这样的文件(一个* .swp第二个* .swo),删除它们(尝试将它们剪切+粘贴到其他目录以防万一)有助于处理错误并成功合并。


1
我解决了冲突,然后使用-a选项提交。 这对我有用。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接