How does `git replace` work and when might it be used?
AdvancedConceptHooks, submodules, LFS and signing
Answer
It creates a ref under refs/replace/ so that Git transparently substitutes one object for another on read, without rewriting history. It has been used to graft old history onto a trimmed repo after a migration. Replacement refs are local unless pushed.
git replace --graft <new-root> <old-tip>
More on Hooks, submodules, LFS and signing
What are Git hooks and where do they live?BeginnerHow do you share hooks with a team, given `.git/hooks` is not committed?IntermediateWhat does the `commit-msg` hook receive and what is it good for?IntermediateWhat do `pre-receive` and `update` hooks do and how do they differ?AdvancedWhat is a Git submodule?BeginnerWhy do submodules confuse people and what are the common pitfalls?Intermediate