How can I reduce the ever-increasing time to push a subtree?
No, unfortunately not. When you run git subtree push
, it will recreate all commits for this subtree. It has to do that, as their SHA depends on the previous commit and needs those SHAs to be able to link the new commits to the old ones. It could cache that, but it doesn’t.
I guess this is the price you pay for using subtree vs. submodules. Subtree is very stateless in your repository, which is nice on the one hand but causes these long computations on the other hand. Submodules store all their information which requires you to manage it but also makes stuff like this a lot faster.
Try using the --rejoin
flag, so that after the split the subtree is correctly merged back to your main repository. This way each split needs not to go through all history.
git subtree split --rejoin --prefix=<prefix> <commit...>
From the original subtree documentation:
After splitting, merge the newly created synthetic history back into your main project. That way, future splits can search only the part of history that has been added since the most recent --rejoin.