If I run git replace --graft SHA on a simple test repo, it seems to correctly truncate the repo (with respect to the provided SHA) when viewed via git log.
However on a more complicated repo when I try the same thing, it instead seems to 'replace' the original commit with another - and it keeps all the previous commits surprisingly. The only difference seems to be that the commit has a gpg signature:
git replace --graft af3b4b8a5f98db343b7fc05789aa9656e786d080
warning: the original commit 'af3b4b8a5f98db343b7fc05789aa9656e786d080' has a gpg signature
warning: the signature will be removed in the replacement commit!
Why is this happening? And how can I correctly make it truncate the commit log?
Surprisingly it correctly seems to show that the commit has no parent (if I try reference af3b4b8a5f98db343b7fc05789aa9656e786d080~1) yet git log still shows commits before it.
git log af3b4b8a5f98db343b7fc05789aa9656e786d080~1
fatal: ambiguous argument 'af3b4b8a5f98db343b7fc05789aa9656e786d080~1': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
The repo in question is https://github.com/eugenp/tutorials and the commit I'm grafting is af3b4b8a5f98db343b7fc05789aa9656e786d080.
So I'm basically doing:
git clone https://github.com/eugenp/tutorials
cd tutorials
git replace --graft af3b4b8a5f98db343b7fc05789aa9656e786d080
git log | tail -n 10 # this shows commits before af3b4b8a5f98db343b7fc05789aa9656e786d080 hence it's not truncating
git log --graph --decorate --oneline.git logthough - if I'm on the master branch -git logshould only show commits in the master branch? I see the same result if I dogit log master. I'm not sure what significance the graph log would show?--first-parent, then try them both it again withgit --no-replace-objectsinstead of justgit. The commit whose ancestry you're (locally) rewiring was merged in from a side branch. Only its unmerged ancestry is no longer reachable from the master tip.--first-parentor--no-replace-objects. I don't understand what you mean by the commit ancestry being from a side branch either. Reading your reddit reply is only slightly helping me understand the underlying git structure of what I'm trying to achieve. This graft commit could surely have references to the appropriate blobs/trees without previous commits being referenced as well.