git submodule
git
Aufruf
git submodule update --init --recursiveBindet 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
| Option | Bedeutung |
|---|---|
| add <url> <path> | pin another repository at a path |
| update --init | fill in a submodule folder that a clone left empty |
| --recursive | go into submodules of submodules |
| update --remote | move the pin to the tip of the tracked branch |
| status | the commit each submodule sits at |
| deinit <path> | unregister it |
| foreach <cmd> | run a command in each one |
Beispiele
git submodule update --init --recursivethe command that fills empty submodule folders after a clone
git submodule add https://github.com/x/lib.git vendor/libadds a dependency as a submodule
git submodule update --remoteupdates 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