Auto commit git hash of submodule in superproject

When committing in the git submodule, you need to go to the superproject to execute the second commit, which is the new hash of the submodule.

It is incredibly annoying, easy to forget, and can cause all kinds of problems if you do not.

What I want to do:

  • Commit changes to my submodule
  • Let the hash automatically execute in the superproject
  • And both the submodule and the superproject are pushed to their remote start ('git push')

What is the best way to find out if you are in a submodule, where is a super project, etc., and automate this?

Maybe some post-commit hook in the submodule?

+6
source share
1 answer

Have you tried git-slave ? This is exactly what he had to do.

You can also script to do this yourself. Keep in mind that there are two options in the git command itself, which can help a lot: --work-tree and --git-dir . Using them, you can act on any repo without leaving the current directory.

Then there is also git submodule foreach --recursive git push .

+5
source

Source: https://habr.com/ru/post/905335/


All Articles