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

后端 未结 3 1375
一生所求
一生所求 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:48

    There exist differences!

     git submodule update --init --recursive
    

    will register direct dependent submodules and clone them down, then go into next depth, register submodules and clone them recursively. Finally, all directly or indirectly dependent submodules will be registered and cloned from the remote. If there exists cyclic dependency, this command will never terminate.

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

    This command follows the template:

    git submodule foreach --recursive "your command"
    

    which means that firstly, "git submodule foreach --recursive" will generate a submodules set, then in each submodule, your command gets executed. However for a initial project without executing "git submodule init" and then "git submodule update", "git submodule foreach --recursive" will be empty, so "your command" won't take place at all.

提交回复
热议问题