GitPython: How to check whether a submodule is on needed commit?

29 views Asked by At

Want to check whether the submodule is already on the correct commit after the repo branch is changed. For example: Suppose for a repository named sample there are two submodules itemA and itemB. Following are some set of commands as an example -

cd sample

git checkout master

git ls-files submodules/itemA

abcdefgh

git ls-files submodules/itemB

zxcvbnma

So which GitPython commands to use to check whether each submodule is already on the commit listed using ls-files or not? If the submodule is already on right commit, skip fetching it else fetch it again to get to right commit.

Also not sure how to use ls-files in gitPython to get submodule commit id at first place

0

There are 0 answers