Reduce increasing time to push a subtree

旧时模样 提交于 2019-12-03 06:03:38
VonC

Note that if you decide to switch to git submodule, you now can, since git1.8.2 (2013-03-08) track the latest commits of a submodule repo.

See git externals.

"git submodule" started learning a new mode to integrate with the tip of the remote branch (as opposed to integrating with the commit recorded in the superproject's gitlink).

That could be make for quicker push, while benefiting from the additional information a submodule has over a subtree (i.e a lightweight record of a specific commit of the submodule)

You can update that submodule to the latest of a given branch with:

git submodule update --remote

This option is only valid for the update command.
Instead of using the superproject's recorded SHA-1 to update the submodule, use the status of the submodule's remote tracking branch.

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.

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 hand but causes this long computation on the other hand. Submodules store all their information, which requires you to manage it but also makes stuff like this a lot faster.

Maybe this helps: I think you can tell git subtree split to only go back n commits by doing

git subtree split --prefix XXX HEAD~n..

or by specifying the commit you want to start with for example

git subtree split --prefix XXX 0a8f4f0^..

This helps reduce the time, though it's inconvenient.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!