2

I am attempting to update my project folder on my laptop. I was working on it on a iMac and my latest version is on that as well as on GitHub. When I attempt to sync it to my laptop I am getting the following error:

Some uncommitted changes would be over written by syncing. Please commit your changes and try again

The version on my laptop is out dated and I don't want to sync it.

Franck Dernoncourt
  • 77,520
  • 72
  • 342
  • 501
Lonergan6275
  • 1,938
  • 6
  • 32
  • 63

2 Answers2

2

When you get that message you basically have three options:

  1. git reset --hard HEAD -- Destructive. When you do this you'll throw away everything you've done up to that point and be back at the last HEAD before you made any changes.

  2. git commit -- In the middle. With this you're committing your changes which will get rid of the error but if the changes aren't complete its probably superfluous.

  3. git stash -u -- My recommendation. With this you're able to "stash" or set aside the changes you've made up until this point. Then you can pull from a remote without interfering. Once you've done that you can run a git stash pop which will put back all of the changes you've made (without committing them).

Peter Foti
  • 5,526
  • 6
  • 34
  • 47
2

If you are using the GitHub GUI and are not worried about losing the local changes on your laptop but just need to get the latest version from GitHub:

Simply use "discard changes" before attempting to sync. This can be done either for a specific file:

enter image description here

or for all files:

enter image description here

It reverts all selected files to the last committed version. Then you can sync to retrieve the new version from GitHub without any issue.

Franck Dernoncourt
  • 77,520
  • 72
  • 342
  • 501
  • I just got into exact same issue, and your solution worked for me. I wish I could also see which file caused this issue. In order to find that I had to go through manually through the files in the merge request and find out which file is being modified by me and has the latest changes from the other developer. – Mike May 05 '17 at 18:57