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?

Paul Brewczynski
  • 2,575
  • 3
  • 28
  • 41

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,129,465
  • 480
  • 4,036
  • 4,755