开发者

git submodules - trying to debug an elusive problem

We use 开发者_JS百科multiple submodules to keep our code modular. Most developers work in 1 or 2 of them, which makes it nice for them, since they don't have to populate areas of the code they don't care about. We work on branches. The submodules and super project are checked out on the same branch. Now comes the fun part. they make changes in the submodule, add, commit. cd up to the superproject, and repeat the commit to record the new version of the submodule they changed. Then they run supergit pull to update all of the content in their workspace. This should bring in all the latest versions for all submodules. Then they push to deliver. Our build system creates a clone, and populates all of the submodules. It then finds that one of the submodules that the developer had not populated has a commit that hasn't been committed and pushed in the superproject. We fail the build now when this happens, but how can we avoid it? I have asked developers to populate all of the submodules before they push to make sure this doesn't happen, but we have actually seen this problem occur when no changes have been made to the branch. Over the holiday weekend, when no one made changes, one of the branches started to fail the build. Is it possible that git is losing commits to the superproject?


We fail the build now when this happens, but how can we avoid it?

Well, if someone pushes to the parent repo without pushing to the submodule repo, then it's the correct behavior to fail the build. How to avoid it? Make sure that you first push the submodule before you start on the commit and push of the parent project.

Is it possible that git is losing commits?

Short answer: no. Longer answer: it's very unlikely. Git tries hard to maintain consistency of the repository. If you have commits A -> B -> C, then it's impossible to suddenly have A -> C unless you specifically tell git to do that. Of course, git is only a software and all software has bugs, so technically, there is a slight possibility that this can happen, but I really doubt that's your case.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜