Git subtree post hook

2019-07-21 23:08发布

问题:

I would like to be able to update subtrees automatically. I have one repo that consists solely of subtrees from third-party repos, and would like to use a post hook to update these whenever the main repo is pulled.

回答1:

Just as a concern, in development of larger projects it's often important for dependent libraries to remain stable. If you constantly pull the changes automatically you don't have the opportunity to confirm that they don't come with breaking changes for your parent project.

If you're going to do the hook script, I recommend you only fetch but do not pull.

Fetch will update the local copy of the remote, but won't update your working branch to the head.

As for how to implement a hook script:

Here are a couple starting points:

  • http://git-scm.com/book/en/Customizing-Git-Git-Hooks
  • http://githooks.com/