Working on local master branch:
git commit -m "Lots of important commits"
git reset --hard origin/master
How can I retrieve the commits that have been lost as a result of the git reset (from the remote)?
EDIT: note this is not about retrieving uncommitted changes.
If you committed it, nothing is lost.
If you have the reference of the commit, you can just
git reset --hard <sha>
to that precise commit.In case you don't you can always use
git reflog
to retrieve the sha before performing the hard reset.For instance if
git reset --hard origin/master
is the last command you run, you can do