Stuck at "A merge operation in progress"

GitAzure DevopsVisual Studio-2017

Git Problem Overview


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

Git Solutions


Solution 1 - Git

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.

Solution 2 - Git

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

Solution 3 - Git

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.

Solution 4 - Git

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

Solution 5 - Git

I manually deleted the

> index.lock

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

Solution 6 - Git

I had the same issue. Fixed it with:

git reset --hard HEAD

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionBernard Vander BekenView Question on Stackoverflow
Solution 1 - GitRLHView Answer on Stackoverflow
Solution 2 - GitTingting0929View Answer on Stackoverflow
Solution 3 - GithowchengView Answer on Stackoverflow
Solution 4 - GitSeraphim'sView Answer on Stackoverflow
Solution 5 - GitHp_isseiView Answer on Stackoverflow
Solution 6 - GitC. DamocView Answer on Stackoverflow