Get Them Back
Someone ran git reset --hard on main by mistake, and its last commits no longer show in the log. Nothing has been done since. Put main back where it was just before that reset.
Example 1
starts as
* cd7750c (HEAD -> main) two
* 0cbd544 one
nothing to commit
git reflog says:
cd7750c HEAD@{0}: reset: moving to HEAD~2
bb39c58 HEAD@{1}: commit: four
4478d7a HEAD@{2}: commit: three
cd7750c HEAD@{3}: commit: two
0cbd544 HEAD@{4}: commit (initial): oneends as
on branch: main commits, newest first: four three two one staged: nothing changed, not staged: nothing untracked: nothing
Constraints
- 1 to 3 commits were cut off
- Nothing is edited or staged
Write it in your browser, against the clock. The model script, with a note on each command it uses, comes after.
More Git problems
- On Top of MainHard
- Split the CommitHard
- The First Bad CommitHard
- Three Into OneHard
- Undo the MergeHard
- When Was It AddedHard
- A New BranchBeginner
- Back to MainBeginner