Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
`git submodule foreach git pull` in parallel
I use git submodule foreach git pull
to update my submodules. There's quite a few and it appears that foreach
is updating them one by one, instead of in parallel. How can I do it in parallel?
1 answer
Git can't do this natively, but you can use git in combination with another command, such as GNU xargs
First of all, fetching many repos in parallel is likely not worth it. Git fetch is likely to be limited by network speed or drive IO speed, not single core processing speed. Multiple instances of git will compete with each other for these resources, so running them in parallel could take more total time than running them serially.
With that said, you can use git to quickly get a list of submodules, then pipe that list to another command which can launch many instances of git in parallel. For example:
git submodule foreach pwd \
| xargs -I{} --max-procs=8 git -C {} pull
0 comment threads