简体   繁体   中英

Git: how do I make sure I don't commit/push hashes to submodules which haven't been pushed to remote yet?

I'm sure you know the situation but I don't know the correct wording:

I have a repository with a couple of submodules which I work on in the context of the main repository - ie I often have to change the content of the submodules rather than working on them somewhere else separately.

When I've added/committed changes to those submodules, quite often I commit/push the submodules new commit ID but forget to push the submodule itself.

Locally this is no problem and hard to identify but of course the build breaks because even the checkout goes wrong.

I know with git this situation is not easy to handle in a general way because of how remotes work but there must be approaches to avoid this situation.

What is yours? Is there a git intrinsic method?

You have various local configurations to make a simple git push to also include the submodules (meaning you are pushing the submodules and your main project, all in one go)

git config push.recurseSubmodules on-demand
git push

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM