I know I can tell Git to show progress like
Resolving deltas: 98% (123/125)
when passing the command line parameter --progress
to, e.g. the fetch command. But we have a couple of large submodules and there no progress is shown. How to tell Git to also show progress for cloning submodules (e.g. as part of the fetch command)?
If you want to check for new work in a submodule, you can go into the directory and run git fetch and git merge the upstream branch to update the local code. Now if you go back into the main project and run git diff --submodule you can see that the submodule was updated and get a list of commits that were added to it.
Submodules are very static and only track specific commits. Submodules do not track git refs or branches and are not automatically updated when the host repository is updated.
Git submodules may look powerful or cool upfront, but for all the reasons above it is a bad idea to share code using submodules, especially when the code changes frequently. It will be much worse when you have more and more developers working on the same repos.
git submodule sync synchronizes all submodules while git submodule sync -- A synchronizes submodule "A" only. If --recursive is specified, this command will recurse into the registered submodules, and sync any nested submodules within.
Starting with Git v2.11.0, the git submodule
interface accepts the --progress
option which you can use. It does exactly what you expect.
See: https://github.com/git/git/commit/72c5f88311dab7149fcca1f6029414ccb776fee8
--progress
wasn't announced in the help text (git submodule --help
) in earlier versions but now it is (tested with Git version 2.27.0)
The closest I came was to use this command:
git fetch --recurse-submodules=yes --jobs=10
This is not giving you a progress bar. But it speeds up the fetching of the repositories. This helped me a whole lot on a microservice project with ~30 submodules.
Of course, you can combine this with other commands afterwards, for example, update all repositories without potential conflicts:
# run all subprojects updates: Pull on currently selected branches
#git submodule foreach 'git rebase origin/master; true'
git submodule foreach '
export BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
git status -bs
if [[ "master" == $BRANCH_NAME ]]
then
git merge FETCH_HEAD --ff-only
else
echo \"NOTE this branch is $BRANCH_NAME. You must merge/rebase yourself!\"
fi
'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With