Notes on using git-replace to get rid of giant objects
blog.plover.com
blog.plover.com
Another thing: You can work with shallow clones. If the commit is ancient, no need to pull the whole history of a project.
Can you query the server logs somehow? Just because you don't want a complete local copy you would of course still want to be able to query the log and request diffs from any commit.
Use with care, do it on a Sunday (or other time most devs aren't working), and be prepared to restore a backup.
Or change all CI / dev docs to use `--depth`, and save more than 350MB per checkout in the process.
`--depth` is a useful tool. There are still some issues with things like log/blame/annotate in working with more shallow clones. It's hopeful that the work on the commit-graph cache will help make this a lot better.
Good point on log/blame/annotate.
1. checkout the last commit before the bad one.
2. cherry-pick every commit after the bad one.
Would that get rid of the bad commit?
All of these require you to fix everyone's local copy though.
The author wants to avoid rebases because they cannot "stop the world" on the project and have around 350 developers they can't tell to stop working while the rebase effort is done, and then rebase all their current work on top of the new branch history.
Git's current design makes this sort of scenario impossible. Any tampering with commit X after the fact is immediately detectable, and Git will raise an alarm and refuse to check out the commit.
To cover the rollback case in your comment, give git checkout a safe mode (either with the default being safe and requiring —-force to override or an explicit —-safe) that fails if the tree-ish points to any deleted blob.
How to propagate this change is a delicate matter because any fetch may reach back and destructively update my local clone. When I’ve wished for this feature, it has always been in the context of a central team repository. Being able to delete an object from the central repository at least has the benefit of subsequent clones not being bloated by the 350-megabyte file. Presumably people with access to the team’s central repository can be trusted to wield this power responsibly. Other members of the team may optionally run the hypothetical git delete-object ffff9999 to shrink their respective clones. Leaving it as plumbing to be run on a repository to which one has administrative access seems like a decent balance.
This could be a potentially expensive operation because replacing a packed object with a known-but-deleted object would trigger a repack. The ripple effect of this new special case — new object type, really — would be nontrivial and a change that would break backward compatibility.