Cannot trigger post-commit git hook on git submodule

我与影子孤独终老i 提交于 2019-12-06 11:05:19

You can use something like below inside your post-commit hook:

git --work-tree=$PWD/.. --git-dir=$PWD/../.git branch

The above command is taken from .git/modules/my-sub-module/hooks/pre-commit file on my git version 2.3.2 (Apple Git-55). I am using the above command to list all the local branches of the main repo.

NOTE: Unfortunately changing directory and running git-commands inside the post-commit hooks may not work, because of the git relying on some of the preconfigured default settings and env-vars. So in my case cd path-to-main-repo-directory && git some-command inside my .git/modules/my-sub-module/hooks/pre-commit did not help me.

You can also check the manual here for more details.

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