I know the support for git submodules is limited in JGit, but still was wondering how can I achieve this:
git submodule foreach git checkout <branchName>
and similar commands using JGit.
Or is there any other better Java based API for Git?
I know the support for git submodules is limited in JGit, but still was wondering how can I achieve this:
git submodule foreach git checkout <branchName>
and similar commands using JGit.
Or is there any other better Java based API for Git?
In JGit there is a SubmoduleWalk
that might help with your problem. To run a checkout command on all submodules, you would write something along these lines:
try (SubmoduleWalk walk = SubmoduleWalk.forIndex(repository)) {
while(walk.next()) {
try (Repository submoduleRepository = walk.getRepository()) {
Git.wrap(submoduleRepository).checkout().call();
}
}
}