0

I'd like to ask if there is a possible way that a hook is executed on git submodule update; possibly like a post-update hook? thanks! :)

I like to execute a script (for now it just contains echo msg) that is executed every time git submodule update is run.

I have tried post-update hook but it seems that submodule update does not trigger this. I'd appreciate help. thank you very much!

2 Answers 2

3

A post-update, like a post-receive hook, would be a server-side hook.
So it is expected to not work locally (client side)

So there is no specific hook for a git submodule update, which means you would need to script the git command itself in a wrapper, to detect the submodule argument, and chain that command with your echos.

Another convoluted approach is described in "git-submodule with git-hooks — A way to scalable repositories" from Ashwini Kumar, where a pre-commit hook is trigger by a git commit (done after a git submodule update), which will look at the diff introduced by said commit.
If the diff involves submodules, then it proceeds with additional commands.

Sign up to request clarification or add additional context in comments.

Comments

2

Create an alias:

git config alias.sup !"git submodule update; my-post-sup-hook" 

and always update submodules using the alias:

git sup 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.