Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

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).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top