Recover a Commit After git reset with reflog
Recovery may be possible if the local reflog still refers to the commit from before the reset. Check git reflog --date=local and choose the correct HEAD@{n} entry; HEAD@{1} below is only an example.
git reset --hard discards uncommitted changes to tracked files. Back up work you need first and choose a rescue branch name that does not exist. Reflog cannot restore uncommitted edits already lost to a hard reset. For shared history, coordinate with collaborators and usually consider git revert.
| |
Replace HEAD@{1} with the reflog entry you selected and rescue-before-reset with a new branch name. Inspect the commit and confirm the branch was created before running the final command.
