Git submodule commit hooks

你说的曾经没有我的故事 提交于 2019-12-19 05:03:04

问题


I'm using a git submodule (let's call it SubmoduleRepo) so that I can include my module in couple of projects.

I can commit to SubmoduleRepo from any project that uses it.

I can update, commit and push to SubmoduleRepo pretty hassle-free.

I need to execute a commit hook whenever I commit something while working in a directory in a project that contains the SubmoduleRepo (when I work in SubmoduleRepo, the commit hook executes as expected)

There is no .git folder in submodule's dir (only .git file that specifies path to current directory).


回答1:


If you have Git 2.10+ you can get the hooks directory by running:

`git rev-parse --git-path hooks`

Note: by default it is .git/hooks but if you are in a submodule it will be different.

Pre Git 2.10+ you would want something like:

`git rev-parse --git-dir`/hooks

More info at: Find path to git hooks directory on the shell




回答2:


I've found solution couple of moments after posting this...

You can put hooks in .git/modules//hooks/ - eg. .git/modules/web/js/modules/rate if your submodule is located in /web/js/modules/rate directory.



来源:https://stackoverflow.com/questions/10848191/git-submodule-commit-hooks

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