Fortgeschrittenes Git
Amanda Crawford-Adamo
Software and Data Engineer
Git-Submodule
git submodule

Ein Submodule per Link oder Verzeichnis unter einem Pfad hinzufügen.
git submodule add <repository link|dir> <path>
$$
Beispiel
Fügt die Datenvalidator-Bibliothek dem ETL-Projekt im Ordner libs/validator des ETL-Repos hinzu.
git submodule add https://github.com/example/data-validator.git libs/validator
Alle Submodules in einem Projekt auflisten
git submodule status
Beispiel
$ git submodule status
e1f2...7w8x9 data_cleaning_lib
a1b2...q7r8 api_connector
d9e8...t3u2 visualization_toolkit
Submodule mit den neuesten Änderungen aktualisieren
Es gibt mehrere Optionen:
git submodule update --init
git submodule update --init --remote
git submodule update --init <path_to_submodule>
Ein Submodule entfernen
git submodule deinit <submodule_name>
git rm <path>
Kopiere alle Dateien, die in das neue Submodule-Repo sollen, in einen Ordner außerhalb des Repos.
Lege im neuen Ordner ein Repository für das Submodule an:
git init <new-submodule>
Nutze git filter-repo, um relevante Dateien und Historie aus dem Hauptprojekt zu extrahieren:
git filter-repo --path <extract_path> --invert-paths
Füge das extrahierte Repository als Submodule zum Hauptprojekt hinzu:
git submodule add <new-submodule_path> <path_to_store_submodule>
Einsatzszenarien:
Best Practices:
Fortgeschrittenes Git