Start·Terminal-Befehle

git submodule

git

Aufruf

git submodule update --init --recursive

Bindet ein anderes Repository an einem bestimmten Commit in Ihres ein; ein einfacher Klon lässt den Ordner leer, bis update --init läuft, und das Eltern-Repository merkt sich einen Commit, keinen Branch.

Häufige Optionen

OptionBedeutung
add <url> <path>pin another repository at a path
update --initfill in a submodule folder that a clone left empty
--recursivego into submodules of submodules
update --remotemove the pin to the tip of the tracked branch
statusthe commit each submodule sits at
deinit <path>unregister it
foreach <cmd>run a command in each one

Beispiele

git submodule update --init --recursive

the command that fills empty submodule folders after a clone

git submodule add https://github.com/x/lib.git vendor/lib

adds a dependency as a submodule

git submodule update --remote

updates the pinned commit to the branch tip

Verwirrend ist, dass Rückgängig mehrere Formen hat — den Zeiger eines Branch zu verschieben ist nicht dasselbe wie einen Gegen-Commit zu setzen.

So liest man das

  • Eckige Klammern [ ] markieren einen Teil, den man weglassen kann.
  • Drei Punkte … heißen: mehrere sind erlaubt.
  • Optionen achten auf Groß- und Kleinschreibung — bei manchen Befehlen sind -r und -R verschieden.

Häufige Fragen

Q. Was macht git submodule?

Bindet ein anderes Repository an einem bestimmten Commit in Ihres ein; ein einfacher Klon lässt den Ordner leer, bis update --init läuft, und das Eltern-Repository merkt sich einen Commit, keinen Branch.

Q. Wie gibt man ihn ein?

git submodule update --init --recursive — eckige Klammern markieren, was wegfallen darf.

Q. Wie viele Optionen lohnen sich?

Hier stehen 7; die vollständige Liste steht in man git. Der Befehl gehört zu git.

Verwandte Befehle

man-Seite: man git-submodule