How to perform a subtree merge using plumbing commands?

178 views Asked by At

I want to combine a subtree merge into a regular (non-merge) commit. I currently do this by first performing the subtree merge, then amending this with the regular changes.

git merge --strategy subtree --strategy-option subtree=subdir $subdir_parent
# stage changes
git commit --amend -m "message"

Is it possible to perform this operation using only plumbing commands? In the commit generated by git merge, I see no indication of this being a subtree merge commit. When I pass $subtree_parent as the second parent to git commit-tree, the resulting commit fails to include the changes of $subtree_parent.

PS. Are there any objections to adding changes to a merge commit that have nothing to do with the merge?

EDIT I think I understand now. Is it simply the tree of the merge commit that determines how the subtree was merged in? Meaning a subtree of the tree equals the top tree of the second parent.

1

There are 1 answers

0
Brecht Machiels On

Oops. This was just the result of me being confused about how git works. The tree passed to git commit-tree should of course reflect the situation after the merge. I was feeding it the tree without changes to the subdir folder. Simply creating a merge commit using git commit-tree does not magically perform the merge!