GIT-REPAIR(1)
π NAME π
git-repair β fix a broken git repository. that's it, that's the whole job, and honestly? it ate. β¨
π SYNOPSIS π
git-repair [--force]
π¦ DESCRIPTION π¦
okay so bestie, picture this: your git repo is fully going through it. corrupt. broken. the kind of mess where git fsck just stares at it and complains that there are problems β no fix, no advice, just judgement. π
git-repair is the one who shows up with a skincare routine and fixes it. here's the whole method, no gatekeeping:
- it deletes all corrupt objects
- and it retrieves all missing objects that it can from the remotes of the repository
lowkey iconic. π
But what if that's not enough to fully recover the repository? not a problem, it has more moves: it can
- reset branches back to commits before the corruption happened,
- delete branches that are no longer available due to the lost data,
- and remove any missing files from the index.
and it will ONLY do all of that if you run it with the --force option, because that rewrites history and throws out missing data. so like, it's a big deal, it's giving scorched earth, proceed with the vibes of someone who knows what they're doing. π
also important: the --force option never touches tags, even if they are no longer usable due to missing data. it just. will not. periodt.
After running this command, you will probably want to run git fsck to verify it fixed the repository. π«Ά and heads up: fsck may still complain about objects referenced by the reflog, or the stash, if they were unable to be recovered. this command does not try to clean up either the reflog or the stash. not its business, not its problem, it's not doing that. π
And since this command unpacks all packs in the repository, you may want to run git gc afterwards. little post-repair self-care moment. π§
β TESTING β
not me telling you that git-repair is able to test itself?? main character energy fr fr. π
here's how: it makes a temporary copy of the git repository it's run in, damages it in random ways, and then checks that it can repair it so that git fsck reports no problems. like it's out here breaking things on purpose just to prove it can fix them. obsessed. π₯
this is done using the --test parameter and the associated --numtests and --retry parameters. iykyk.
note that the testing will sometimes find repositories that can only be repaired when --force is used β this is expected. no cap, that's normal behavior.
on the other hand, if it fails to recover a repository with --force, then the testing has found a bug! π¨ that's the real deal, that's a genuine problem, go tell someone.
π AUTHOR π
Joey Hess <joey@kitenet.net>
http://git-repair.branchable.com/
and that's the whole page, bestie. π the footer of this manual is literally just an empty () β no source, no version, no date, just a void where the credits should be β so consider this your cute sign-off instead: go fix that repo, run your git fsck, and slay. π¦πΈβ¨
π¦ where this page comes from
- arch rolling: git-repair 1.20230814-260 Β· AGPL-3.0-only
- debian trixie: git-repair 1.20230814-1 Β· AGPL-3.0-or-later
- fedora 43: git-repair 1.20230814-5.fc43 Β· AGPL-3.0-or-later
- fedora 44: git-repair 1.20230814-7.fc44 Β· AGPL-3.0-or-later
- ubuntu questing: git-repair 1.20230814-1
- ubuntu resolute: git-repair 1.20230814-1build1 Β· AGPL-3.0-or-later
- ubuntu stonking: git-repair 1.20230814-1build1 Β· AGPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms