1655

I made a branch called 'f' and did a checkout to master. When I tried the git pull command I got this message:

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

When I try the git status, it gave me the following:

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

What should I do?

Dom
  • 1,687
  • 6
  • 27
  • 37
Ankit Suri
  • 16,490
  • 3
  • 16
  • 19
  • 1
    my issue was that after resolving conflicts, there were not changes to commit, so I had to `git commit --no-edit` as [suggested here](https://stackoverflow.com/a/36189488/6908282) – Gangula Jul 27 '23 at 06:40

24 Answers24

2871

The problem is your previous pull failed to merge automatically and went to conflict state. And the conflict wasn't resolved properly before the next pull.

  1. Undo the merge and pull again.

    To undo a merge:

    git merge --abort [Since git version 1.7.4]

    git reset --merge [prior git versions]

  2. Resolve the conflict.

  3. Don't forget to add and commit the merge.

  4. git pull now should work fine.

ggorlen
  • 44,755
  • 7
  • 76
  • 106
Karthik Bose
  • 33,556
  • 3
  • 33
  • 43
  • 2
    I tried and gave me conflict in files(when pull) Auto-merging app/views/layouts/application.html.erb Auto-merging log/development.log CONFLICT (content): Merge conflict in log/development.log Auto-merging log/restclient.log CONFLICT (content): Merge conflict in log/restclient.log Automatic merge failed; fix conflicts and then commit the result. I fixed the local files specified, and then I tried 'git pull' Pull is not possible because you have unmerged files. Please, fix them up in the work tree, and then use 'git add/rm ' as appropriate to mark resolution, or use 'git commit -a'. – Ankit Suri Jul 26 '12 at 04:00
  • 2
    @AnkitSuri, After fixing the conflicts, did you stage them and commit? – Karthik Bose Jul 26 '12 at 05:21
  • 1
    I tried it and it help me to get on flow again. After revert back I did try "git mergetool". It directly associate with merging tool. – CoDe Dec 26 '13 at 13:02
  • 10
    Does not work: ``[env]$ git merge --abort fatal: You have not concluded your merge (MERGE_HEAD exists). Please, commit your changes before you can merge.`` – user1429980 Jun 03 '14 at 21:55
  • @user1429980: Which version of GIT you are using? did you try `git reset --merge` – Karthik Bose Jun 04 '14 at 03:59
  • 1
    @KarthikBose, it actually did end up working. Since I was working over SSH, I had to start a new session and do a ``git status``. – user1429980 Jun 05 '14 at 19:40
  • @KarthikBose How do you add and commit a merge, since the files that were merged are already added? I get as response only the untracked files and on commit that I have nothing to commit – stelios Oct 26 '16 at 16:07
  • @chefarov After you resolve the conflict, the file needs to be staged. Execute "git add to stage the file. Then "git commit" to commit your merge. You got nothing to commit, after resolve the conflict?? It cud be because you chose local version of the file. Use git gui to commit empty merge. – Karthik Bose Nov 08 '16 at 22:18
  • Thank you very much, `git merge --abort` does the trick. I wasn't able to re-merge after reset all files and this resolved my problem. – Mohammad Zaid Pathan Mar 09 '17 at 14:24
  • after `git merge --abort` I had to do `git pull` again to have a conflict to respond to. Then when I resolved using `Current Change`, VS Code told me there was no change and would not let me commit to complete the merge. So I did everything over again choosing the alternate resolve. – cyrf Jan 05 '21 at 23:19
  • 1
    @cyrf alternatively, after aborting the merge, you should have undo last commit and then stash all changes, after stash you need to pull the latest code and then apply latest stash, by doing those all, then you need to resolve the merge conflicts and it should've worked. – Zeeshan Ali Khan Feb 24 '23 at 10:47
  • `git commit` After relying on VSCode for git operations for some time, I totally forgot how to do the step 3. All I had to do was just commit without options. `git status` was showing nothing to commit but this command brought me to the editor to modify the merge message. – otterb Jun 12 '23 at 20:01
144

If you are sure that you already resolved all merge conflicts:

rm -rf .git/MERGE*

And the error will disappear.

knagode
  • 5,816
  • 5
  • 49
  • 65
104

I think it's worth mentioning that there are numerous scenarios in which the message You have not concluded your merge (MERGE_HEAD exists) could occur, because many people have probably arrived at this page after searching for said message. The resolution will depend on how you got there.

git status is always a useful starting point.

If you've already merged the contents to your satisfaction and are still getting this message, it could be as simple as doing

git add file
git commit

But again, it really depends on the situation. It's a good idea to understand the basics before attempting anything (same link Terence posted): Git - Basic Merge Conflicts

Community
  • 1
  • 1
fantabolous
  • 21,470
  • 7
  • 54
  • 51
  • 7
    Thank you for asking this, for those of us with the simpler type of problem. "Git status" was what a newbie like me needed, to be reminded that the last step of fixing a conflicted merge was the simple command "git commit". – Dana Apr 20 '17 at 21:22
  • This has been really helpful, after checking, I discovered that I needed to add a file I modified unknowingly. – Adesoft Oct 14 '21 at 07:11
91

I think this is the right way :

git merge --abort

git fetch --all

Then, you have two options:

git reset --hard origin/master

OR If you are on some other branch:

git reset --hard origin/<branch_name>
Badr Bellaj
  • 11,560
  • 2
  • 43
  • 44
64

Abort did not work for me. So I had to continue and this is what worked for me:

git merge --continue
Aakash
  • 21,375
  • 7
  • 100
  • 81
22

Try

git reset --hard origin/trunk

'trunk' is the branch that I am trying to get to.

I don't know how or why this works. It had something to do with some commit I made which was forcing my pull requests to do a merge.

Aakash
  • 21,375
  • 7
  • 100
  • 81
Franklin
  • 329
  • 2
  • 2
14

Commit merge changes solved my problem:

git commit -m "commit message"
Aakash
  • 21,375
  • 7
  • 100
  • 81
sai
  • 239
  • 1
  • 3
  • 7
13

I resolved conflicts and also committed but still getting this error message on git push

All conflicts fixed but you are still merging.
(use "git commit" to conclude merge)

I did these steps to resolve error:

rm -rf .git/MERGE*
git pull origin branch_name 
git push origin branch_name
Aakash
  • 21,375
  • 7
  • 100
  • 81
Taimoor Changaiz
  • 10,250
  • 4
  • 49
  • 53
13
git merge --abort

This code fixed my problem.

Sunil Sapkota
  • 918
  • 2
  • 11
  • 24
11

Just run this command for aborting the conflict:

git merge --abort

After that, you can pull your project:

git pull origin YOUR_BRANCH

Tested git version 2.25.1

Pejman Kheyri
  • 4,044
  • 9
  • 32
  • 39
8

Git commit with add flag solved my problem:

$ git commit -am "commit message"
user8128167
  • 6,929
  • 6
  • 66
  • 79
6

Try changing any temporary file. Like just remove any space or add space and then commit and push that file.

git add 'temporary_change_file'

git commit -m "git issue resolving"

git push origin develop

And then try git pull,

git pull origin develop

Hope this might help you.

Community
  • 1
  • 1
Kazim Noorani
  • 263
  • 3
  • 6
5

In my case I had a cherry pick that produce a number of Merge Conflicts, so I decide to not complete the cherry pick. I discarded all my changes. Doing so put me into a state where I received the following error:

You have not concluded your merge (MERGE_HEAD exists

To fix the issue I performed the following git command which fixed the problem.

git cherry-pick --abort
Aakash
  • 21,375
  • 7
  • 100
  • 81
5

I got this issue when I had two commits with same messages. What fixed my issue is,

git add.
git commit -m "New commit message"
Nupur Sharma
  • 1,106
  • 13
  • 15
4

Blockquote

If you're trying to pull from another branch into your branch. If you're seeing this error.

First, you should try doing git commit and then pull another branch into yours.

  1. "git add . "
  2. git commit
  3. Then do git pull from the required branch.
Rohith
  • 327
  • 4
  • 12
4

We can use git merge --continue with git version 2.12 and above to continue your merging after resolved the conflict. Can see this answer

Pyae Hlian Moe
  • 339
  • 3
  • 3
3

Best approach is to undo the merge and perform the merge again. Often you get the order of things messed up. Try and fix the conflicts and get yourself into a mess.

So undo do it and merge again.

Make sure that you have the appropriate diff tools setup for your environment. I am on a mac and use DIFFMERGE. I think DIFFMERGE is available for all environments. Instructions are here: Install DIFF Merge on a MAC

I have this helpful resolving my conflicts: Git Basic-Merge-Conflicts

Terence
  • 288
  • 3
  • 3
1

first,use git pull to merge repository save your change.then retype git commit -m "your commit".

Jack loner
  • 11
  • 3
1

I resolved the conflict and then do a commit with -a option. It worked for me.

Svetoslav Marinov
  • 1,498
  • 14
  • 11
1

First, make sure there are no conflicts before proceeding.

Check if there is no MERGE_MSG.* file in your .git folder.

I knew there are no conflicts and somehow I´ve got 2 of those (one *.swp second *.swo) and deleting them (try maybe to cut+paste them to some different directory just in case) helped to handle the error and merge successfully.

h_a_l_a_s
  • 56
  • 5
1

This message is shown when you are in the middle of a merge. These steps worked for me to finish the merge:

  1. stage files with the resolved conflicts,
  2. commit, you may need to create an empty commit.

And you are done, now it should be possible to pull again.

Martin Staufcik
  • 8,295
  • 4
  • 44
  • 63
1

Run git status and it will tell you what to do.

For example, in my case it was the message: All conflicts fixed but you are still merging. (use "git commit" to conclude merge)

Indeed, running git commit solved the problem.

0

For those using SourceTree and don’t wanna jump to the terminal to hit and try these commands. Just commit with any message without any changes and it will be resolved.

Tabish Sohail
  • 1,040
  • 2
  • 9
  • 22
-12

This worked for me:

git log
`git reset --hard <089810b5be5e907ad9e3b01f>`
git pull
git status
Bob Gilmore
  • 12,608
  • 13
  • 46
  • 53
Plus1
  • 7