I have read the following articles:
- Git Tools - Submodules
- git-submodule
- Git Submodules: Adding, Using, Removing, Updating
- easy-way-pull-latest-of-all-submodules
But I still do not 100% understand submodule handling. My questions are:
- What does
git submodule update
do? Is it the same as doinggit submodule foreach git pull
? - What is the difference to
git submodule update --force
? - What is the difference to
git submodule sync
? And when do I have to call update and when do I have to call sync? This question is a bit longer. I had to trigger a
git submodule update --init —recursive
. But why did nogit submodule update --force
orgit submodule sync
help? Please regard the following history of commands and outputs. I am sorry for the terrible formating. But I am somehow not able to insert this as code.- cd $gitproject - cd submodule_a - git status - ad96e1a11:og-appconfig-android knoppik$ git status - On branch develop - Your branch and 'origin/develop' have diverged, - and have 1 and 5 different commits each, respectively. - (use "git pull" to merge the remote branch into yours) - nothing to commit, working directory clean - cd .. - git pull - git submodule update --force - git submodule sync - cd submodule_a - git status - ad96e1a11:og-appconfig-android knoppik$ git status - On branch develop - Your branch and 'origin/develop' have diverged, - and have 1 and 5 different commits each, respectively. - (use "git pull" to merge the remote branch into yours) - nothing to commit, working directory clean - cd .. - rm -rf submodule_* - git submodule update --init --recursive - Submodule path ’submodule_a’: checked out '8d4d756f2342bc373b6e86f0d0246f7b502ba796‘ - git status - On branch develop - Your branch is up-to-date with 'origin/develop'. - nothing to commit, working directory clean - cd submodule_a - git status - HEAD detached at 8d4d756 - nothing to commit, working directory clean
So why did git submodule update --force
not work? Why did I have to delete the submodule folders and run an init once again?