Interview Prep/Git & GitHub/Hooks, submodules, LFS and signing

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>
All Git & GitHub questions Roadmap: Git & GitHub

More on Hooks, submodules, LFS and signing