'git submodule update --init --recursive' VS 'git submodule foreach --recursive git submodule update --init'

后端 未结 3 1388
一生所求
一生所求 2020-12-23 16:12

I have git repo which has nested submodules. What is the difference between below 2 commands?

git submodule update --init --recursive

git submodule foreach         


        
3条回答
  •  北荒
    北荒 (楼主)
    2020-12-23 16:44

    git submodule update --init --recursive
    

    The submodule update command will recurse into the registered submodules, update and init (if required) them and any nested submodules within.

    git submodule foreach --recursive git submodule update --init
    

    foreach will evaluate the command in each checked out submodule. So it will update and init (if required) each submodule and any nested submodules within due to --recursive.

    So in the end, both commands will achieve the same thing. Simply the execution differs, the first command won't step into each directory to execute the command.

提交回复
热议问题