How to use 'git filter-branch' to update SHA submodule?

Suppose I have two repositories Git, A and B. B - submodule A.

For simplicity, suppose also that I have a magic function get_sha_B , which, given the SHA commit from A, returns the desired SHA commit for B.

How to start the filter branch on repo A so that each commit of repo A is rewritten to indicate the required commit of repo B, how get_sha_B was returned?

Thanks!

+4
source share
1 answer

I thought! I am going to answer my question here:

I can use git update-index in combination with git filter-branch --index-filter .

Here's how to call update-index to modify the sub-module SHA commit:

 git update-index --cacheinfo 160000 88e6a302c42840440f9faac73f27efc6a3e0c1a6 pathto/mysubmodule 

As far as I understand, 160,000 is the magic number in Git, used to identify the submodule.

+3
source

All Articles