Recover a lost commit
Use git reflog to recover commits lost after a hard reset or deleted branch. Walks through finding the lost SHA and creating a new branch from the recovered state.
Preview
Copy prompt
I accidentally deleted a branch or ran git reset --hard and have lost commits that were not pushed to any remote. My current git log output is: [Paste output]. Walk me through the exact steps to use git reflog to locate the lost commits by their SHA. Show the git checkout or git branch command to recover them onto a new branch. Explain how to verify that the recovered commits contain the expected changes and describe the safest way to rebase or merge the recovered work back into the main branch.
More
Git & Version Control
Prompts
