2

I have read the following articles:

  1. Git Tools - Submodules
  2. git-submodule
  3. Git Submodules: Adding, Using, Removing, Updating
  4. easy-way-pull-latest-of-all-submodules

But I still do not 100% understand submodule handling. My questions are:

  1. What does git submodule update do? Is it the same as doing git submodule foreach git pull?
  2. What is the difference to git submodule update --force?
  3. What is the difference to git submodule sync? And when do I have to call update and when do I have to call sync?
  4. This question is a bit longer. I had to trigger a git submodule update --init —recursive. But why did no git submodule update --force or git 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?

Community
  • 1
  • 1
unlimited101
  • 3,653
  • 4
  • 22
  • 41

0 Answers0