# Git

## Git und Submodule

Quelle:[https://stackoverflow.com/a/1032653](https://stackoverflow.com/a/1032653)

<div aria-describedby="--stacks-s-tooltip-yv4t4xf6" aria-label="Accepted" data-controller=" s-tooltip" data-s-tooltip-placement="right" id="bkmrk-"><div><svg aria-hidden="true" class="svg-icon iconCheckmarkLg" height="36" viewbox="0 0 36 36" width="36"></svg></div></div><div id="bkmrk--0"><div data-post-id="1032653"></div></div>If it's **the first time** you check-out a repo you need to use `--init` first:

<div id="bkmrk-git-submodule-update"><div><div>```
git submodule update --init --recursive

```

</div></div></div>For **git 1.8.2** or above, the option `--remote` was added to support updating to latest tips of remote branches:

<div id="bkmrk-git-submodule-update-0"><div><div>```
git submodule update --recursive --remote

```

</div></div></div>This has the added benefit of respecting any "non default" branches specified in the `.gitmodules` or `.git/config` files (if you happen to have any, default is origin/master, in which case some of the other answers here would work as well).

For **git 1.7.3** or above you can use (but the below gotchas around what update does still apply):

<div id="bkmrk-git-submodule-update-1"><div><div>```
git submodule update --recursive

```

</div></div></div>or:

<div id="bkmrk-git-pull---recurse-s"><div><div>```
git pull --recurse-submodules

```

</div></div></div>if you want to pull your submodules to latest commits instead of the current commit the repo points to.

See [git-submodule(1)](https://www.kernel.org/pub/software/scm/git/docs/git-submodule.html) for details