1

We have a product repo which refers to many submodules - say:

product->document
       ->examples
       ->code
etc

Now I have made changes to "code" repo. So my changes goes to "code" repo / develop and its build goes fine. Note that my changes however is yet to be merged in "code" repo develop branch

Now I am in need to build 'product' repo with my modified 'code' submodule such that I can check our changes in an environment - note only "product" repo creates product executable. The "product" repo refers to submodules develops branch. Hence until my code is delieverd to "code" develop branch I am unable to build a "product" build with my changes.

In other words the "product" repo needs to be build that points to the my "code" submodule.

I tried below way - checkout a "product" branch and tried to cherry-pick / merge changes in "code" repo to have my code repo changes:

user$ /c/product> git checkout -b feature/test_my_code_changes

user$ /c/product> (feature/test_my_code_changes)
$ git cherry-pick 44b591ca3266ad54d7c09c7dd55d2b65501a4077
fatal: bad object 44b591ca3266ad54d7c09c7dd55d2b65501a4077


user$ /c/product> (feature/test_my_code_changes)
$ git merge 44b591ca3266ad54d7c09c7dd5654323401a4077
merge: 44b591ca3266ad54d7c09c7dd5654323401a4077 - not something we can merge

The above command fails - I believe that cause the commit ids belongs to "code" submodule of my changes - how can I achieve the objective and verify that my "product" repo is refering or having my submodule / changes and then start a "product" build?

Programmer
  • 8,303
  • 23
  • 78
  • 162

1 Answers1

0

You could make the submodule code follows the branch used before merfing to develop in your product repository.

That way, a simple git submodule update --remote would be enough to force a pull of the develop branch in submodule code.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • "develop branch in submodule code" - but my code changes in code repo is not delievered to code develop – Programmer Jan 31 '20 at 05:26
  • @Programmer which branch are you using then? – VonC Jan 31 '20 at 05:28
  • I am using "product" branch - updated my submodule "git submodule init" followed by "git submodule update --remote". Now I cd'ed tp code directory and checkout out my feature branch made changes and push to code repo - a pull request is generated and not yet approved. So my requirement is that the product repo to be build with my code submodule changes – Programmer Jan 31 '20 at 05:32
  • @Programmer OK, so change the branch followed by the submodule code in the product repo, as I describe in https://stackoverflow.com/a/18799234/6309 – VonC Jan 31 '20 at 05:34
  • Thanks though I have not tried all the commands but do we need to execute all the commands as mentioned in the link - the post is quiet elaborative and has many things I believe - just a query from my side – Programmer Jan 31 '20 at 05:38
  • @Programmer the first 4 dots are relevant in that link. – VonC Jan 31 '20 at 05:39
  • Just one last query - but once the objective is achieved how do I revert back to original settings meaning to refer back to existing submodules - the changes to be made is temporary to just verify my changes – Programmer Jan 31 '20 at 05:42
  • @Programmer You change again the branch followed by the submodule to "develop". And update the submodules again. – VonC Jan 31 '20 at 05:45
  • Just another last additional query - is there a way to vierfy the changes - I mean I keep a record before making the changes and make the changes - verify and then revert and verify - how can I verify the changes – Programmer Jan 31 '20 at 05:50
  • When you make the changes to your gitmodules, you can commit them and do a git diff. – VonC Jan 31 '20 at 06:01