59

Steps

  • In Visual Studio
  • Pulled from remote repo
  • 1 merge conflict
  • Merged manually, clicked 'Accept merge'

Result

  • Message: "A merge operation is in progress in the ... repository. Commit your changes to complete the merge operation."
  • However, there is nothing to commit: There are 0 pending changes, no actions apart from Abort seem to be possible.

Screenshot: https://pbs.twimg.com/media/DBOeRIiXsAEbnLP.jpg

Context

  • Remote git repo is hosted in Visual Studio Team Services
  • Visual Studio 2017 with all updates
Bernard Vander Beken
  • 4,848
  • 5
  • 54
  • 76
  • 4
    The first thing I would do here would be to run `git status` from the Git bash. What does that tell you? – Tim Biegeleisen Jun 01 '17 at 10:06
  • $ git status On branch develop Your branch and 'origin/develop' have diverged, and have 1 and 2 different commits each, respectively. (use "git pull" to merge the remote branch into yours) nothing to commit, working directory clean – Bernard Vander Beken Jun 01 '17 at 10:16
  • 1
    I have never used Git in Visual Studio, but it's perfectly possible that there are bugs like this. – Tim Biegeleisen Jun 01 '17 at 10:19
  • Thanks Tim, I was able to manually commit the changes via Git bash. Seems like a bug in Visual Studio. – Bernard Vander Beken Jun 01 '17 at 10:20
  • The Eclipse eGit plugin also had a number of annoying known bugs last time I used that IDE. For this and other reasons, I usually choose to use the bash. Glad to help you. – Tim Biegeleisen Jun 01 '17 at 10:23
  • @BernardVanderBeken, if you find yourself in this state again, I would love to try and debug it further. In the Git integration in Visual Studio, we call git status and parse the output to determine the state of the repo. We also check for specific files in the .git directory similar to how Git determines an operation is in progress. In this particular scenario, it told us that there was a merge in progress, which usually happens if there were conflicts that had been resolved but the merge hadn't been completed. Apparently we did not pick up that the merge was in fact completed. – Chad B Jun 01 '17 at 13:25
  • @ChadB do you have a list of things to do when/if this occurs again? – Bernard Vander Beken Jun 01 '17 at 14:58
  • Similar behavior remains in VS 2019 - the Commit Merge button is disabled until you add a comment to the merge commit for the process to complete, and you have to navigate to another part of Team Explorer to do this. – PJ7 May 19 '20 at 14:00
  • Does this answer your question? [TFS error: Merge must finish before the Pull Request can be completed](https://stackoverflow.com/questions/46728924/tfs-error-merge-must-finish-before-the-pull-request-can-be-completed) – Jim G. Jun 23 '21 at 18:20
  • @Jean-François Fabre: I voted to close as duplicate. – Jim G. Jun 23 '21 at 19:16

7 Answers7

81

I had a very similar problem with one of my projects which gave me the same TFS message in Visual Studio 2017. I was also using git. In my case I needed to manually add a comment to the commit before posting the merge. Since I had to manually merge the conflicts, a comment was needed rather than the auto-populated message that takes place on a merge without conflicts.

I'm well aware that commits need comments but if I recall correctly, VS 2015 would auto-populate the comment on a merge, even if you manually fixed any merge issues. Regardless, in VS 2017 you will need to add a commit comment when there are resolved conflicts.

RLH
  • 15,230
  • 22
  • 98
  • 182
  • 4
    You're right! I didn't fill in a commit message (before a merge), a that's why I got stuck at the same moment like in this topic. What I did: I did a small/not important change in one file, and commited it with filling a comment message. In fact, when I checked the history, in this commit was included not only this one little change, but also all merged files. After this - everything works normally. Thanks a lot! – Ursula Oct 02 '17 at 09:51
  • 14
    The message is so misleading. It should change to say "enter a comment" instead of looking like a process is still running. – JohnOpincar Nov 01 '17 at 19:04
  • 2
    It's amazing. I also just added a new comment manually and after this the commit button is available for using. – Taras Pelenio Jun 22 '20 at 12:55
37

When get conflicts during a pull action from remote Git repository in Visual Studio, you need to do a manual merge to choose Remote or Local version. After you click 'Accept merge', you need to commit this merge operation. You will see that like this picture below.

enter image description here

If you doesn't see this window, you could also commit from pending changes window. You can see that there's nothing under Changes tab. This is because you choose local version when you merge. Of cause, there's no file changes to show under Changes. But you still need to commit the merge operation.

enter image description here

Tingting0929
  • 4,142
  • 1
  • 14
  • 14
  • Thanks, I will try this approach when I can reproduce the issue again. – Bernard Vander Beken Jun 02 '17 at 06:58
  • @BernardVanderBeken maybe you could create a small test to verify. Like change a file in one local repository and push to VSTS. Then in another repository, edit the same file and commit. After that pull from remote. You will get a conflict. – Tingting0929 Jun 02 '17 at 07:05
2

If you have Git for Windows (gitk) installed, you can open a command window, navigate to your repo's local directory and launch it, then from the File menu, choose "Start git gui". At that point, you will see that you the merge to be committed and you can do it from there. Then either from gitk or back in Visual Studio, you can now push all your commits back to the origin.

howcheng
  • 2,211
  • 2
  • 17
  • 24
1

I had the same issue. Fixed it with:

git reset --hard HEAD // **WARNING**: this will remove your current work, so better stash/backup it

Note: You can check the last commit ID by:

git rev-parse HEAD // will display the last commit ID

OR

git reset --hard <last_commit_ID>

OR

git reset --soft <last_commit_ID> // this will only move the pointer
C. Damoc
  • 476
  • 4
  • 9
0

I used an external Tool like Fork to Abort thre merge. Inside VS nothing seems to work.

Seraphim's
  • 12,559
  • 20
  • 88
  • 129
0

I manually deleted the

index.lock

file from the .git folder which resolved the issue for me.

Hp_issei
  • 579
  • 6
  • 18
0

In my case VS was stuck showing "ApplyMailboxInProgress"

The cause turned out some wrong command I had run from the command-line. I had to abort it running

git am --abort
JHBonarius
  • 10,824
  • 3
  • 22
  • 41