我已阅读以下文章:
但我仍然不会100%了解子模块处理。我的问题是:
git submodule update
做什么?是否与git submodule foreach git pull
一样?git submodule update --force
有什么区别?git submodule sync
有什么区别?我什么时候需要调用更新,什么时候需要调用同步?这个问题有点长。我不得不触发git submodule update --init —recursive
。但为什么没有git submodule update --force
或git 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
那么为什么git submodule update --force
不起作用?为什么我必须删除子模块文件夹并再次运行init?