I ran git reset --hard / deleted my branch. Are my commits gone?
No — almost certainly not. Git keeps every commit you ever made in .git for at least
30 days after it becomes unreferenced. Here is the complete recovery procedure:
Step 1 — Look at the reflog (your safety net)
git reflog
Every place HEAD has ever been is listed, newest first, e.g. a1b2c3d HEAD@{0}: reset: moving to origin/main.
Find the commit from before the destructive command.
Step 2 — Restore to a branch
# whole working state back: git reset --hard a1b2c3d # or, safer — keep current state too: git branch rescue/a1b2c3d a1b2c3d
Step 3 — If reflog doesn't show it: search dangling objects
git fsck --lost-found git show <hash> # inspect each candidate git cherry-pick <hash> # or branch from it
Deleted branch specifically?
The tip commit is in the first lines of git reflog as checkout: moving from X to Y —
or just: git reflog | grep -i delete, then git branch <name> <hash>. Done.
Why this works: reset --hard moves pointers, it does not delete objects. GC only prunes
unreachable commits after 30 days (gc.reflogExpire). Act within the window and you lose nothing.
Unlock the full guide — founding rate
First 20 buyers lock $2-equivalent forever (then $5). Remaining founding slots are counted only from verified settlements — no fake counters here.
Send exactly 2.54 USDC (≈ $2.44 at order time — founding rate) on BASE to:
| Amount | 2.54 USDC |
| Network | BASE |
| Address | 0x05FE364d9Ee3Dc0063878C286aF8b3074819Ca5B |
| Order ID | 77646bab5f92 |
| Status | waiting for your transaction… (auto-checks every 15 s — no refresh needed) · raw status |
The moment settlement lands on-chain, this page unlocks itself — the full guide fades in below. No email, no account, no refresh.
Full guide unlocked — 52 rescue scenarios
Order 77646bab5f92 verified settled. Thank you — founding rate locked.
Reset & Amend (10)
Undo last commit, keep changes staged
git reset --soft HEAD~1
Undo last commit, keep changes unstaged
git reset HEAD~1
Undo last N commits entirely
git reset --hard HEAD~3
Destructive to working tree — stash first.
Fix the wrong message on the LAST commit
git commit --amend -m 'correct message'
Amend a pushed commit safely
git commit --amend … && git push --force-with-lease
--force-with-lease refuses if someone else pushed.
Change author of last commit
git commit --amend --author='Name <e@x.com>' --no-edit
Unstage everything
git restore --staged :/
Discard local edits to one file
git restore path/to/file
Recover AFTER a bad reset --hard
git reflog && git reset --hard HEAD@{1}Find a commit by its message text
git log --all --grep='fix login' --oneline
Rebase Disasters (8)
Abort an interactive rebase mid-flight
git rebase --abort
Undo a COMPLETED rebase
git reflog && git reset --hard 'HEAD@{5 minutes ago}'Skip a commit that now conflicts
git rebase --skip
Resolve conflict during rebase, continue
git add . && git rebase --continue
Squash last 3 commits into one
git reset --soft HEAD~3 && git commit -m 'one'
Reorder/drop commits interactively
git rebase -i HEAD~5
Mark rows pick/drop/edit/squash.
Rebase without changing commit hashes you already pushed
git pull --rebase --autostash
Recover a branch someone force-pushed over
git reflog show origin/main && git reset --hard <hash>
Stash Rescue (6)
Stash including untracked files
git stash -u
List stashes with what's inside
git stash list --stat
Recover a DROPPED stash
git fsck --no-reflogs --lost-found && git stash apply <hash>
Dropped stashes survive until gc — grab the dangling commit.
Apply stash without removing it
git stash apply stash@{1}Pop conflicts cleanly
git stash pop || git checkout --theirs . && git stash drop
Stash only some files
git stash push -m 'wip auth' file1 file2
Merge Recovery (6)
Abort a conflicted merge entirely
git merge --abort
Undo an already-made merge (before push)
git reset --hard ORIG_HEAD
Undo a PUSHED bad merge
git revert -m 1 <merge_sha>
-m 1 keeps the branch you merged INTO.
Keep both versions of every conflict
git merge --no-commit … ; git checkout --conflict=diff3 .
See exactly which files conflict
git diff --name-only --diff-filter=U
Redo the same merge after fixing
git merge --continue
Deleted Files & Branches (6)
Restore a file deleted but never committed
git restore path/to/file
Restore a file deleted IN a past commit
git checkout <commit>^ -- path/to/file
Recover deleted branch
git reflog | grep -i delete ; git branch name <hash>
List ALL commits on all branches+stash+tags
git log --oneline --graph --all --decorate
Find commits not on any branch (orphans)
git fsck --unreachable --no-reflogs
Recover uncommitted work after checkout -f
git fsck --cache --no-reflogs --lost-found --dangling
Blob-level rescue: extract via git cat-file -p.
Remote & Push Repair (6)
Undo a wrong push to shared branch
git revert <sha> && git push
Never rewrite shared history.
Remove a secret from the last commit only
git rm --cached secrets.env && git commit --amend --no-edit && git push --force-with-lease
Point a moved remote branch back
git update-ref refs/remotes/origin/main <good_hash>
Fetch PR refs that vanished
git fetch origin 'refs/pull/*/head:refs/remotes/pr/*'
Delete a tag on the remote
git push origin :refs/tags/v1.2.3
Push was rejected (non-fast-forward)
git pull --rebase && git push
History Surgery (6)
Scrub a file from ALL history
git filter-repo --invert-paths --path secrets.env
filter-repo, not filter-branch. Reinstall remotes after.
Rewrite author across all history
git filter-repo --email-callback 'return b"new@x.com" if email==b"old@x.com" else email'
Split one big commit into several
git rebase -i <before> , mark edit, then git reset HEAD^ && re-stage piecemeal
Cherry-pick onto another base cleanly
git cherry-pick -x <sha>
-x records provenance for future archaeology.
Find when a line changed (even moved)
git log --follow -p -- path/file
Binary-search the bug commit
git bisect start ; git bisect bad ; git bisect good v1.0
Tags & Releases (4)
Retag a release without breaking clones
git tag -d v1.2 && git tag -a v1.2 -m 'fixed' <sha> && git push --tags --force-with-lease=v1.2
Turn a lightweight tag annotated
git tag -a v1 $(git rev-parse v1) -f
Find the commit a tag really points to
git rev-parse v1^{commit}Recover a deleted annotated tag object
git fsck --lost-found | grep tag ; git tag v1 <sha>