68

I am using Git in Visual Studio. When I am trying to synchronize, the following message appears:

An error occured. Detailed message: An error was raised by libgit2. Cetegory = checkout(MergeConflict). 1 conflicts prevent checkout

I don't have a clue about what the conflicts are and how to fix them. Can anyone help me overcome this problem?

DavidRR
  • 18,291
  • 25
  • 109
  • 191
Jim Blum
  • 2,656
  • 5
  • 28
  • 37
  • 3
    This may help you understand how to get to the somewhat "hidden" `Resolve conflicts` UI in Visual Studio: http://stackoverflow.com/a/28720255/114029 – Leniel Maccaferri Feb 25 '15 at 13:29

8 Answers8

57

I have solved the same problem by using the Git command prompt in Visual Studio, because it gives you more ability:

http://msdn.microsoft.com/en-us/library/vstudio/dd286572.aspx

You also may install this extension to facilitate the work with it (it gives you ability do not enter passwords each time):

http://gitcredentialstore.codeplex.com/

Then I used this commands:

git pull // I got an error on this step
git stash
git pull

more information about commands here:

http://git-scm.com/docs/git-pull

http://git-scm.com/book/en/Git-Tools-Stashing

http://git-scm.com/docs/git-commit

And as CharlesB said it is due to "conflict between your changes and the changes from another branch".

Maks
  • 2,808
  • 4
  • 30
  • 31
  • 2
    Okay, what you actually do is just moving your open changes to another 'stash' to continue afterwards from it. Please mind this while you do. Another option would be to undo all your pending changes (which are not excluded) – Highmastdon Nov 30 '14 at 00:20
  • 2
    If you're interested in solving this from Visual Studio instead of doing it from the command line, please upvote: https://visualstudio.uservoice.com/forums/121579-visual-studio-2015/suggestions/4576531-provide-stash-support-in-visual-studio-tools-for-g – gwenzek Oct 19 '15 at 16:55
  • I couldn't see any issue in Visual Studio. VS said all my files were up to date but I couldn't switch to a branch. Used the command line to try to check out the branch and it told me there was a conflict with the .suo file. I used command line to stash that file and then it let me switch branches. – Caverman Jul 30 '21 at 22:27
44

You have some uncommited changes. Commit or undo those changes and then Git "pull" will work.

DavidRR
  • 18,291
  • 25
  • 109
  • 191
Dachi
  • 817
  • 1
  • 9
  • 17
3

I experienced this issue during a "pull" request via Visual Studio.

There was a change to a hidden file: .ntvs_analysis.dat

To discover this hidden file and remedy the problem, I:

  1. Showed hidden files just to see if there were changes to files that I could not see.
  2. In the project directory, used Git GUI to undo the change to the hidden file that I found.

After that, my "pull" request was successful.


Control Panel => Folder Options => View => Show hidden files and folders

DavidRR
  • 18,291
  • 25
  • 109
  • 191
3

I had this issue and the way I resolved it was by "brute force"...I had no changes to commit, and no commits to sync but still got this error while trying to pull in some changes that another developer pushed.

I ended up just whacking my local repo in the file system and re-cloning the remote branch. Voila!

Perhaps not the most elegant solution, but it works if you don't have any local changes that you are worried about losing.

How 'bout a Fresca
  • 2,267
  • 1
  • 15
  • 26
0

if you have some changes in local then you just commit your changes and dont sync this commit

changes => Enter a Commit Message => Commit and don't Sync this commit,then you can pull correctly

if you have not changes in your branch then go on Actions => Open Comment Prompt => then enter this lines

  1. git pull

  2. git stash

3.git pull

0

Our environment requires us to not rely on Nuget auto package restore, and the problem I experienced was due to:

  • Some members only use GIT command console to commit / pull / push.
  • I rely on VS2013 Git tools to do Commit / pull /push.
  • The Git command console pushes all the content in the packages folder
  • Visual Studio tools ignores the packages folder

So the conflict was due to files in the packages folder trying to be added via the VS pull, but already existed on the HDD. For now I just deleted the relevant packages folder/files and redid the pull, that worked.

Hope this helps.

Neville
  • 545
  • 1
  • 4
  • 19
0

This sounds like the result of not adding executables and other auto generated output from Visual Studio to a .gitignore file. You don't want to be source controlling those files. More information on this here.

Community
  • 1
  • 1
ngm_code
  • 141
  • 1
  • 9
-1

when I change one branch to another that time I get the error so I close the Visual Studio and re-open Visual Studio it work for me

  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/32346532) – Simas Joneliunas Aug 01 '22 at 02:27