I am trying to use git replace to rewrite history and replace the commit tree with a tree object of another commit. I want to make it permanent.
The documentation for git replace seems like this is possible. I adapted the following recipe to replace the commit from How do I add the past to the git repository? .
this works, the master tree has been replaced with master2, including an additional file:
100644 blob 3b18e512dba79e4c8300dd08aeb37f8e728b8dad readme.txt 100644 blob 16b14f5da9e2fcd6f3f38cc9e584cef2f3c90ebe testfile.txt
However, trying to make this permanent, it fails:
git filter-branch --tag-name-filter cat -- --all
gives the following answer from git:
Rewrite e7619af3e5d424a144845c164b284875c4c20c7a (2/2) WARNING: Ref 'refs/heads/master' is unchanged WARNING: Ref 'refs/heads/master2' is unchanged error: Object bc705106db90164b2e688b4b190d4358f8b09a56 is a tree, not a commit error: Object bc705106db90164b2e688b4b190d4358f8b09a56 is a tree, not a commit fatal: ambiguous argument 'refs/replace/e7a75e980c7adc0d5ab1c49ecff082b518bb6cf8^0': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git <command> [<revision>...] -- [<file>...]' WARNING: Ref 'refs/replace/e7a75e980c7adc0d5ab1c49ecff082b518bb6cf8' is unchanged
and after I remove the replacement link, the master gets its original tree back:
git replace -d ${ORIG} git ls-tree master 3b18e512dba79e4c8300dd08aeb37f8e728b8dad readme.txt
Why is git filter-branch complaining about replacing and how do I do this replacing the tree permanently?
PS I know that I can do this with filter-branch --tree-filter or grafts, but (how) can I do this with git replace ?
git
fraco
source share