Including git subtree with git cherry-pick, but the squash commit operates in the root directory

42 Views Asked by At

I am trying to include git subtrees as a subproject in different branches in my project. The git subtrees consist of two commits: a merge commit and a squash commit. The merge commit has the information about which subdirectory the subtrees should land in, which is used by the root directory and the squash commit. The cherry pick command separates the merge commit and the squash commit so I get duplicate files in the right subdirectory from the merge commit and in the root git directory from the squash commit as it no longer take part of the subdirectory-info from the merge commit.

Any idea on how I can fix this? Can I somehow make the commits "connected" again? Or is there another way of doing it? I want to keep the squash commit

So I tried doing

git cherry-pick -m 1 <merge commit> <squash commit> 

It added all the files twice: in the right subdirectory and the root git directory

When I added the subtrees I did the command

git subtree add --prefix <prefix> <link to subtree> <from what revision> --squash

Very thankful for any help

0

There are 0 best solutions below