<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/some-things-are-never-truly-lost---how-git-recovered-two-weeks-of-deleted-work-vh20yles6" -->

---
title: Some things are never truly lost - How git recovered two...
description: A developer accidentally reset a 46-commit feature branch to main and force-pushed, wiping out two weeks of work on a major version upgrade. In a panic, he...
canonical: https://daily.dev/posts/some-things-are-never-truly-lost---how-git-recovered-two-weeks-of-deleted-work-vh20yles6
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Some things are never truly lost - How git recovered two weeks of deleted work | daily.dev
og:description: A developer accidentally reset a 46-commit feature branch to main and force-pushed, wiping out two weeks of work on a major version upgrade. In a panic, he...
og:url: https://daily.dev/posts/some-things-are-never-truly-lost---how-git-recovered-two-weeks-of-deleted-work-vh20yles6
og:image: https://api.daily.dev/og/posts/vh20yles6.png
og:image:alt: Some things are never truly lost - How git recovered two weeks of deleted work
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Some things are never truly lost - How git recovered two weeks of deleted work

**[Daniel Saidi](https://daily.dev/sources/danielsaidi)** · 5 min read · 7 upvotes · 1 comments

## Summary

A developer accidentally reset a 46-commit feature branch to main and force-pushed, wiping out two weeks of work on a major version upgrade. In a panic, he asked Claude Code, which pointed him to git's reflog and dangling commits, ultimately recovering the deleted branch with a single 'git branch -f' command. The story explains why deleted refs, rebased commits, and force-pushed history aren't actually destroyed in git, just unreferenced, and stay recoverable for 30 days by default.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://danielsaidi.com/blog/2026/08/27/some-things-are-never-truly-lost>

## Questions this post answers

### How can I recover a git branch that was accidentally reset and force pushed?

Find the commit hash of the last commit before the reset, then run git branch -f <branch-name> <commit-hash> to recreate the branch pointing at that commit. Deleted or dangling commits typically remain in git's object database for about 30 days by default, even after a reset and force push, because deleting a ref only removes a label, not the underlying commit objects.

_Developers hunting for a lost branch after a bad reset can find similarly grounded git recovery stories on daily.dev._

### Does git rebase delete the original commits it rewrites?

No, rebasing does not destroy the original commits; it writes new commits and moves the branch pointer, while the old commits remain accessible. Every rebase operation logs a 'rebase (start)' entry in the reflog that records the tip you were on before the rebase ran, so both the before and after states survive and can be recovered.

_Anyone nervous about rebasing production branches can browse practical git safety lessons on daily.dev._

### Can Claude Code help recover lost git commits after a force push?

Yes, an AI coding assistant with a live session in a local repository can check the git reflog and dangling objects to locate commits that no longer have a branch name pointing to them. In one recovery case, it identified the exact commit hash before a disastrous reset, allowing a single git branch -f command to restore an entire deleted branch.

_Developers curious how AI coding assistants handle real debugging emergencies can find such accounts on daily.dev._

## Community discussion

Top comments from developers on daily.dev.

**@pdfopsdev** · 0 upvotes

> worth noting git's actually got two different clocks here, reflog entries pointed at by a ref default to 90 days (gc.reflogExpire) and only unreachable ones drop to 30 (gc.reflogExpireUnreachable). saved me once when I assumed the 30-day number applied to everything.

## Similar posts on daily.dev

- [I Force Pushed Over Six Hours of Commits. I Didn’t Tell Anyone.](https://daily.dev/posts/i-force-pushed-over-six-hours-of-commits-i-didn-t-tell-anyone--kskxx8fez) · JavaScript in Plain English · 18 upvotes · 5 comments
- [Someone Force-Pushed main. The Commits Weren’t Gone — reflog Still Had Ninety Days](https://daily.dev/posts/someone-force-pushed-main-the-commits-weren-t-gone-reflog-still-had-ninety-days-enoq7avkg) · Medium · 12 upvotes · 2 comments
- [The Git Recovery Guide: How to Undo Anything \(Without Panic\)](https://daily.dev/posts/the-git-recovery-guide-how-to-undo-anything-without-panic--alupd6iws) · DEV · 1 upvotes · 0 comments
- [Git Rebase Deleted Nothing. Your Commit Is Still in the Reflog.](https://daily.dev/posts/git-rebase-deleted-nothing-your-commit-is-still-in-the-reflog--fczn8gdo7) · Medium · 0 upvotes · 0 comments

---

Tags: [#git](https://daily.dev/tags/git), [#swift](https://daily.dev/tags/swift), [#claude-code](https://daily.dev/tags/claude-code), [#version-control](https://daily.dev/tags/version-control)

[View this post on daily.dev](https://daily.dev/posts/some-things-are-never-truly-lost---how-git-recovered-two-weeks-of-deleted-work-vh20yles6)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Some things are never truly lost - How git recovered two weeks of deleted work","url":"https://daily.dev/posts/some-things-are-never-truly-lost---how-git-recovered-two-weeks-of-deleted-work-vh20yles6","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/some-things-are-never-truly-lost---how-git-recovered-two-weeks-of-deleted-work-vh20yles6"},"datePublished":"2026-08-27T11:54:33.600Z","dateModified":"2026-09-13T20:47:45.768Z","description":"A developer accidentally reset a 46-commit feature branch to main and force-pushed, wiping out two weeks of work on a major version upgrade. In a panic, he...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/e451a7b230e1bfb8705265f36eea1353?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/e451a7b230e1bfb8705265f36eea1353?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Daniel Saidi","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Daniel Saidi","logo":"https://media.daily.dev/image/upload/s--RRuTMOCm--/f_auto,q_auto/v1783235599/logos/danielsaidi?_a=BAMAMicg0","url":"https://daily.dev/sources/danielsaidi"},"commentCount":1,"discussionUrl":"https://daily.dev/posts/some-things-are-never-truly-lost---how-git-recovered-two-weeks-of-deleted-work-vh20yles6","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":7},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":1}],"keywords":"git,swift,claude-code,version-control","timeRequired":"PT5M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Daniel Saidi","item":"https://daily.dev/sources/danielsaidi"},{"@type":"ListItem","position":3,"name":"Some things are never truly lost - How git recovered two weeks of deleted work"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/some-things-are-never-truly-lost---how-git-recovered-two-weeks-of-deleted-work-vh20yles6","comment":[{"@type":"Comment","text":"worth noting git’s actually got two different clocks here, reflog entries pointed at by a ref default to 90 days (gc.reflogExpire) and only unreachable ones drop to 30 (gc.reflogExpireUnreachable). saved me once when I assumed the 30-day number applied to everything.","datePublished":"2026-08-29T18:08:21.642Z","url":"https://daily.dev/posts/vh20yles6#c-WwTLbbyIC","author":{"@type":"Person","name":"PDFops","url":"https://daily.dev/pdfopsdev","image":"https://media.daily.dev/image/upload/s---8isRBKc--/f_auto/v1782922291/avatars/avatar_orjMeK8QKaaVZwGq7ScPz?_a=BAMAMicg0"}}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/some-things-are-never-truly-lost---how-git-recovered-two-weeks-of-deleted-work-vh20yles6#faq","mainEntity":[{"@type":"Question","name":"How can I recover a git branch that was accidentally reset and force pushed?","acceptedAnswer":{"@type":"Answer","text":"Find the commit hash of the last commit before the reset, then run git branch -f \u003cbranch-name\u003e \u003ccommit-hash\u003e to recreate the branch pointing at that commit. Deleted or dangling commits typically remain in git's object database for about 30 days by default, even after a reset and force push, because deleting a ref only removes a label, not the underlying commit objects. Developers hunting for a lost branch after a bad reset can find similarly grounded git recovery stories on daily.dev."}},{"@type":"Question","name":"Does git rebase delete the original commits it rewrites?","acceptedAnswer":{"@type":"Answer","text":"No, rebasing does not destroy the original commits; it writes new commits and moves the branch pointer, while the old commits remain accessible. Every rebase operation logs a 'rebase (start)' entry in the reflog that records the tip you were on before the rebase ran, so both the before and after states survive and can be recovered. Anyone nervous about rebasing production branches can browse practical git safety lessons on daily.dev."}},{"@type":"Question","name":"Can Claude Code help recover lost git commits after a force push?","acceptedAnswer":{"@type":"Answer","text":"Yes, an AI coding assistant with a live session in a local repository can check the git reflog and dangling objects to locate commits that no longer have a branch name pointing to them. In one recovery case, it identified the exact commit hash before a disastrous reset, allowing a single git branch -f command to restore an entire deleted branch. Developers curious how AI coding assistants handle real debugging emergencies can find such accounts on daily.dev."}}]}
```

