git: given an old submodule branch, how would one checkout the corresponding main module version?

StackOverflow https://stackoverflow.com/questions/22367277

  •  13-06-2023
  •  | 
  •  

Question

I have an old submodule branch. I did not make a corresponding topic branch for the main module since my changes only modify the submodule. I have since updated my main module as I and others have been working on stuff. I want to go back to that old submodule branch now and work on it some more but since then, the main module has had updates that depend on changes to the sub module so when I checkout the old submodule, the IDE complains about missing things it expects. My main module is calling things that don't exist yet in my submodule branch.

How do I identify a version of the main module that is compatible with that old submodule branch? Should I try updating the old branch? What is the normal workflow standard for this use case? Should one always just create a topic branch for all modules and submodules to avoid this problem or is there an easier solution?

Was it helpful?

Solution

Should I try updating the old branch?

That would be the main recommendation: from within your submodule, rebase your old branch on top of the SHA1 currently expected by your main parent repo.

If your old branch was used by other, don't use rebase, and instead merge the expected SHA1 to your branch.

In both cases, your branch will include your modifications as well as the SHA1 that the parent repo depends on.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top