Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show progress for submodule fetching?

Tags:

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)?

like image 670
Thomas S. Avatar asked Oct 05 '15 08:10

Thomas S.


People also ask

Does git fetch update submodules?

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.

Do submodules automatically update?

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.

Are git submodules a good idea?

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.

How do I sync submodule?

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.


2 Answers

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)

like image 160
kfunk Avatar answered Sep 18 '22 16:09

kfunk


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
'
like image 25
Jesper Rønn-Jensen Avatar answered Sep 17 '22 16:09

Jesper Rønn-Jensen