Instead of Committing Files, I hit 'Sync'

2019-09-05 04:38发布

问题:

Which Git then proceeded to sync (overwrite) files from my repository (not github), to my local files. I have lost an entire day or more of work.

Is there a way to revert what happened? What did happen? I am side myself.

Rich

回答1:

If the application stashed the changes instead of removing them you will be able to restore it. Try this:

git stash list

Hopefully you'll get an output stash@{0}: ..., which should be easily restored with:

git stash apply

However if there is more than one stash you'll need to call:

git stash apply stash@{number}

If it's more complicated, look into docs for stashing.

Note that if there's no stash, the uncommited changes are gone. Forever. If you don't have an editor that preserves changes or has some backups then I don't think there's anything you can do.