git submodule (1)

Date: 2021/08/28 (initial publish), 2021/09/13 (last update)

Previous Post Top Next Post


The git submodule update --init is nice. I checked how all these repos are managed.

If I want to move submodule, I don’t need delete and clone again. I can simply move it with “git mv <oldpath> <newpath>” while we keep using the same local copy of repo.

Let’s see how this is done.


This file is checked in to the parent Git repository and contains:

[submodule "pack/github/opt/ale"]
        path = pack/ale
        url =

The checked out repo can be moved by git mv.


This is created by git submodule in the submodule directory and has gitdir: ../../.git/modules/pack/github/opt/ale in it pointing to where local bare cloned repo exists. – PATH_BARE


This is deep in the subdirectory of the parent Git repository’s .git directory where the bare clone of submodule repository exists.

        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
        worktree = ../../../../../../pack/ale
[remote "origin"]
        url =
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master


This is in the parent Git repository’s .git and its main configuration. For submodule, this has:

[submodule "pack/github/opt/ale"]
        active = true
        url =
Previous Post Top Next Post