了解git子模块的拉动和推动

时间:2016-07-15 13:43:00

标签: git git-submodules

我已阅读以下文章:

  1. Git Tools - Submodules
  2. git-submodule
  3. Git Submodules: Adding, Using, Removing, Updating
  4. easy-way-pull-latest-of-all-submodules
  5. 但我仍然不会100%了解子模块处理。我的问题是:

    1. git submodule update做什么?是否与git submodule foreach git pull一样?
    2. git submodule update --force有什么区别?
    3. git submodule sync有什么区别?我什么时候需要调用更新,什么时候需要调用同步?
    4. 这个问题有点长。我不得不触发git submodule update --init —recursive。但为什么没有git submodule update --forcegit submodule sync有帮助?请考虑以下命令和输出历史。对于可怕的格式化我很抱歉。但我不知道能不能将其作为代码插入。

              - 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
      
    5. 那么为什么git submodule update --force不起作用?为什么我必须删除子模块文件夹并再次运行init?

0 个答案:

没有答案
相关问题