dennisbot
dennisbot

Reputation: 948

Undo "git reset --merge"

I just did:

git reset --merge

and I lost my latest modifications to some files, how do I undo this last action?

Upvotes: 5

Views: 3455

Answers (2)

Kirill Kay
Kirill Kay

Reputation: 901

I just came across this terrible advice to run git reset --merge while trying to resolve VSCode induced unwanted merge. Very weird state of repo, and as the question mentions, git reset --merge wipes out uncommitted changes, yet git does NOT warn about this to happen.

Anyway, if you're in VSCode with local file history on, you can somewhat recover from this by opening files with lost changes and reverting them to last saved state. This works in case you remember where you had uncommitted changes... if you don't remember however, you're totally out of luck I guess.

enter image description here

Upvotes: 0

Simon Boudrias
Simon Boudrias

Reputation: 44649

you can look at your reflog to find the commit at wich you were before:

git reflog

Once you find your previous commit, copy the sha-1 hash and

git reset <commit sha-1> --hard

Although, if what you lose was uncommitted modifications, well then they're lost.

Upvotes: 6

Related Questions