您尚未完成合并(MERGE_HEAD存在)


1033

我做了一个名为“ 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

我该怎么办?

Answers:


1916

好。问题是您以前的拉动无法自动合并并进入冲突状态。在下一次拉动之前,冲突没有得到正确解决。

  1. 撤消合并并再次拉。

    撤消合并:

    git merge --abort [自git版本1.7.4起]

    git reset --merge [以前的git版本]

  2. 解决冲突。

  3. 不要忘记添加并提交合并。

  4. git pull 现在应该工作正常。


2
我尝试过并在文件中产生冲突(拉出时)自动合并app / views / layouts / application.html.erb自动合并log / development.log冲突(内容):在log / development.log中合并冲突自动合并log / restclient.log CONFLICT(内容):log / restclient.log中的合并冲突自动合并失败;解决冲突,然后提交结果。我修复了指定的本地文件,然后尝试执行“ git pull”,因为您有未合并的文件,所以无法进行Pull。请在工作树中对其进行修复,然后根据需要使用'git add / rm <file>'来标记分辨率,或使用'git commit -a'。
Ankit Suri 2012年

1
@AnkitSuri,解决了冲突之后,您上演了冲突并提交了吗?
Karthik Bose

1
我尝试了一下,它帮助我再次流行起来。恢复后,我确实尝试过“ git mergetool”。它直接与合并工具关联。
CoDe

4
不起作用:[env]$ git merge --abort fatal: You have not concluded your merge (MERGE_HEAD exists). Please, commit your changes before you can merge.
2014年

1
@KarthikBose,实际上确实可以正常工作。由于我使用SSH,因此必须开始一个新会话并执行git status
user1429980 2014年

97

如果您确定已经解决了所有合并冲突:

rm -rf .git/MERGE*

错误将消失。


2
如果删除MERGE_HEAD,结果提交是否只有一个父项,因此就没有合并分支的历史记录?
杰森·古玛

2
这就是我想要的
raditya gumay

1
就我而言,@ JasonGoemaat是我暂时合并尚未被接受的多个PR。我不打算在功能分支上提交这些合并,而在开发过程中只需要它们。
安迪

我已经解决了冲突,但仍然遇到此错误。因此,该命令对我有用。
锡比哈19'Apr

这使我摆脱了令人讨厌的合并冲突循环。
雪橇

68

我认为值得一提的是,在许多情况下You have not concluded your merge (MERGE_HEAD exists)都可能出现该消息,因为许多人可能是在搜索了该消息后才到达此页面的。分辨率将取决于您的到达方式。

git status 始终是一个有用的起点。

如果您已经满意地合并了内容,但仍然收到此消息,则可能很简单

git add file
git commit

但是,这实际上取决于情况。在尝试任何操作之前,先了解基础知识是一个好主意(Terence发布了相同的链接): Git-基本合并冲突


感谢您向我们这些问题类型较为简单的人提出这个问题。需要提醒我的是,像我这样的新手需要“ Git状态”,解决冲突合并的最后一步是简单的命令“ git commit”。
Dana

17

我认为这是正确的方法:

git merge --abort

git fetch --all

然后,您有两个选择:

git reset --hard origin/master

或如果您在其他分支机构:

git reset --hard origin/<branch_name>

2
只有git merge --abort自己工作了&& git pull然后
幸运的

8

我解决了冲突并且也犯了错,但仍然收到此错误消息 git push

所有冲突已解决,但您仍在合并中。
(使用“ git commit”结束合并)

我执行了以下步骤来解决错误:

rm -rf .git/MERGE*
git pull origin branch_name 
git push origin branch_name

什么是push在年底完成?
Mark Storer

6

尝试

git reset --hard origin/trunk

“ trunk”是我要尝试到达的分支。

我不知道这怎么运作或为什么运作。它与我所做的某些提交有关,这迫使我的请求请求进行合并。


5

尝试更改任何临时文件。就像只是删除任何空间或添加空间,然后提交并推送该文件一样。

git添加'temporary_change_file'

git commit -m“解决git问题”

git push起源开发

然后尝试git pull,

git pull起源开发

希望这对您有帮助。


4

块引用

如果您试图从另一个分支拉入您的分支。如果您看到此错误。

首先,您应该尝试执行git commit,然后将另一个分支拉入您的分支。

  1. “ git添加。”
  2. git提交
  3. 然后从所需分支执行git pull。

3

在我的情况下,我有一个樱桃选择会产生许多合并冲突,因此我决定不完成该樱桃选择。我放弃了所有更改。这样做会使我进入以下错误状态:

您尚未完成合并(MERGE_HEAD存在

为了解决这个问题,我执行了以下git命令来解决问题。

git cherry-pick --abort

2

最好的方法是撤消合并,然后再次执行合并。通常,您会弄乱事情的顺序。尝试解决冲突,使自己陷入混乱。

因此,撤消操作,然后再次合并。

确保您具有适合您的环境的差异工具设置。我在Mac上使用DIFFMERGE。我认为DIFFMERGE适用于所有环境。说明在这里:在MAC上安装DIFF合并

我对解决冲突有帮助:Git Basic-Merge-Conflicts


1

首先,使用git pull合并存储库保存您的更改git commit -m "your commit"。然后重新输入。


0

提交合并更改解决了我的问题:

git commit -m "commit message"

-12

这为我工作:

git log
`git reset --hard <089810b5be5e907ad9e3b01f>`
git pull
git status

3
首先,这将删除所有工作目录更改。同样,硬编码版本也无济于事,也许像HEAD ^这样的版本更好。
Entomo

@ Plus1这正是我所需要的-删除错误的本地提交并针对更改后的源代码应用更改。谢谢您的回答!
amuliar

在我的情况下,这引起了一个问题
Shafiq,
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.