JJ Asghar
JJ Asghar

Reputation: 609

Why isn't git submodule init and git submodule update one command?

Whenever I use submodules in git find myself doing

git submodule init
git submodule update

What's the logic in two commands when you basicly do those commands every time?

Upvotes: 0

Views: 359

Answers (3)

awsleiman
awsleiman

Reputation: 1909

They do have a way to do it in one call:

submodule update --init

source : https://git-scm.com/docs/git-submodule#Documentation/git-submodule.txt-init--ltpathgt82308203

Upvotes: 0

mipadi
mipadi

Reputation: 410662

git submodule init initializes the machinery, whereas git submodule update pulls in new changes for the submodules. If you're adding a submodule, there's nothing to update yet, so you only need to run git submodule init to initialize the repo. (It creates a .gitmodules file, as well as some stuff in .git/ for tracking submodules.)

Upvotes: 1

Lance Woodson
Lance Woodson

Reputation: 84

Not sure about the separation, but an easy workaround would be to use an alias.

alias gitrox="git submodule init && git submodule update"

Upvotes: 1

Related Questions