15

I'm working with another developer and we seem to have got ourselves into a GIT pickle. I commit code regularly and regularly push to the remote master. My colleague (whilst a great guy and developer) has not got into the habit of doing this and when I went to Pull the Head revision this morning (as is my habit), I was faced with the following error message:

Cannot pull because there are uncommitted changes. Commit or undo your changes before pulling again. See the Output window for details.

I then noticed there were 5 incoming commits dating back to 5 days earlier. I have no local commits at all and no staged changes.

I've tried Sync'ing, pulling and everything else I could in the VS interface to no avail.

Has anyone else experienced this and can they help me resolve it please.

Thanks

onefootswill
  • 3,707
  • 6
  • 47
  • 101
  • 2
    If you go to command line and run `git status` - do you see any pending changes? Try and the command line running `git reset --hard` to get rid of any changes (if you think you don't need them and then try `git pull`. – First Zero Jan 31 '14 at 01:57
  • I ran git status. It noted that my branch and master had diverged. It noted I had 1 commit and master had 5 commits each. I only added the 1 commit locally by changing 1 file to see if doing a local commit would help. Otherwise, I can lose my local commit. But I don't want to blow away the 5 commits of my colleague. It also noted there were a bunch of untracked files. That it known and we don't want to track those. If I do a git reset --hard, will I lose the 5 remote/incoming commits? – onefootswill Jan 31 '14 at 02:33
  • No the `git reset --hard` was to rollback any uncommitted git files, this was to address `Cannot pull because there are uncommitted changes`. It doesn't touch commits. If you are in branch `master`, just run `git pull`, your local commit and the 5 commits upstream will merge (not as one but as the 6 separate commits). That is what git is designed for. – First Zero Jan 31 '14 at 02:47
  • It has nothing to do with *commits*, it has to do with *uncommitted changes*. Commit your changes, or discard them, then do the pull so that you can merge his changes with yours. – Edward Thomson Jan 31 '14 at 02:57
  • Also, you can see the Output Window for details. – Edward Thomson Jan 31 '14 at 02:57
  • When I try to do a Pull, I get the following error message : An error occurred. Detailed message: An error was raised by libgit2. Category = Checkout (MergeConflict). 3 conflicts prevent checkout – onefootswill Jan 31 '14 at 02:59
  • @EdwardThomson The Output Window is empty and has no details. – onefootswill Jan 31 '14 at 03:00
  • @FirstZero So with pull not working, what are my options? – onefootswill Jan 31 '14 at 05:16
  • You are almost there! :) You have conflicts, ie. you & the other person have touched the same file and `git` is unable to figure out which line should be merged, you have to resolve them by hand, have a look at these links on how to resolve (VS Studio provides a gui for helping you resolve them) => http://msdn.microsoft.com/en-us/library/dd286559.aspx, http://githowto.com/resolving_conflicts, https://help.github.com/articles/resolving-a-merge-conflict-from-the-command-line – First Zero Jan 31 '14 at 06:49
  • @FirstZero Unfortunately, Visual Studio never shows me a link, "Resolve the Conflicts". So I never get the opportunity to perform a merge. I only see the error about libgit2. And I cannot use the bash shell as my authentication is only successful via Visual Studio. It fails when I use Git for Windows or other git tools. – onefootswill Jan 31 '14 at 09:10
  • You can still use gitbash for Windows for resolving merges, committing at the very least, push can be done via Visual Studio. Looking at a previous question in stackoverflow => http://stackoverflow.com/questions/18782637/visualstudio-an-error-was-raised-by-libgit2-category-checkout you need to use git on commandline to resolve the issue. Just run through the commands provided, at the very least find the merge issue, correct it, commit it. Then back into Visual Studio to push the merge back upstream. – First Zero Jan 31 '14 at 09:35
  • Here is another link, are you using `git submodules`? - http://visualstudiogallery.msdn.microsoft.com/abafc7d6-dcaa-40f4-8a5e-d6724bdb980c/view/Discussions/1 – First Zero Jan 31 '14 at 09:36
  • @FirstZero Unfortunately I cannot use Git Bash. Every time I try a git pull, I am prompted to authenticate. And authentication fails every time. I have no idea why, as authentication via Visual Studio is not a problem. I am on Visual Studio 2014 and that extension is not supported. So I'm confined to the narrow channel of the Team Explorer tab in Visual Studio. – onefootswill Jan 31 '14 at 10:00
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/46509/discussion-between-first-zero-and-onefootswill) – First Zero Jan 31 '14 at 11:29
  • this still exists in VS 2015. Total pain! – ozz Dec 11 '15 at 14:28
  • @FirstZero thanks for you first comment, your suggestion worked for me. I was facing this problem is visual studio and solved using GitBash. – Muhammad Sohail Jan 12 '16 at 14:07

1 Answers1

23

I had the same problem, because a number of package files were removed on the server which were not being used. I had to open command prompt and see all errors by running:

git pull

I saw this error with a list of files to remove:

Please move or remove them before you can merge.
Aborting. 

After removing them I was able to successfully do a pull.

Scott Koland
  • 739
  • 9
  • 18
katesky8
  • 572
  • 6
  • 9
  • 1
    You’re probably right. I never did resolve that one. Since then, I have learnt how to use git at the command line and always resolve my errors there. – onefootswill Apr 03 '14 at 03:36
  • You are right, for me I use pull from Visual Studio and get a An error occurred. Detailed message: Could not rmdir ...': Accès refusé. Then I make a git status and show file in error status – Jerome2606 Dec 14 '15 at 19:16