HomeBlogMagic

Git und Submodule

Init Submodule

Creating a submodul within a git repository will create an additional file named .gitmodules wich has to be added later to minor repository.

Here a sample to add CcOS to a given submodule:

git submodule add git://github.com/AndyD87/CcOS.git CcOS

Update Submodule

Submodules will not automatically becomes updated with updates to minor project. It has to be done manually every time a newer version of sumodule is required.

Sample to update submodules:

# Update a single submodule like CcOS
git submodule update CcOS
# Update all submodules
git submodule update

Get Submodules after Clone

Submodules must be cloned separatly with

git submodule init
git submodule update

Change Remote address

Sollte sich die remote Adresse vom submodul geändert haben, ist es notwendig die Adresse aus zu tauschen.

Dazu kann die .gitmodules bearbeitet werden.
Dafür muss nach dem richtigen Eintrag gesucht werden und darin die url ausgetauscht werden.

Beispiel von meinem CcOS wo ich git:// zu https:// ändern musste:

# File before change
[submodule "CcOS"]
        path = CcOS
        url = git://github.com/AndyD87/CcOS.git

# Git changed to https
[submodule "CcOS"]
        path = CcOS
        url = https://github.com/AndyD87/CcOS.git

Checkout remote branch for commit

Wenn Änderungen im Submodul vorgenommen werden, können diese standardmäßig nicht commit werden. Dazu muss der Branch noch einmal explizit ausgewählt werden:

git checkout -f -B master origin/master
  • -B für Overwrite existing
Permalink: https://adirmeier.de/Blog/ID_144
Tags: Blog, git, sources, toolsvon am 2017-07-19