1

Every time I switch to different branch via SourceTree it executes this command (besides switching branch command)

git -c diff.mnemonicprefix=false -c core.quotepath=false -c credential.helper=sourcetree submodule update --init --recursive 

What's the point of it?

Paweł Brewczynski
  • 2,665
  • 3
  • 30
  • 43

1 Answers1

2

A submodule is referenced in the parent repo as a gitlink, a special entry in the index, which points to the SHA1 of the sub-repo.

Whenever you are switching branch, that entry can change, meaning the sub-repo should be checked out again, at a different SHA1.

That is exactly what a git submodule update --init does.

the init and update subcommands will maintain submodules checked out and at appropriate revision in your working tree.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250