Git submodules
Use other repositories inside a Ghost repository with git submodules.
A repository on Ghost can contain git submodules. Add them as with any other host:
git submodule add ../lib.git vendor/lib
git commit -m "Add lib"
git pushClone with the submodules checked out:
git clone --recurse-submodules https://ghost.example.com/octo/app.gitAfter a pull that moves a submodule, run git submodule update, or pull with --recurse-submodules.
Relative URLs
Prefer a relative URL such as ../lib.git for a submodule that lives on the same Ghost instance. Git resolves it against the URL the superproject was cloned from, so a clone over SSH fetches the submodule over SSH and a clone over HTTPS fetches it over HTTPS with the same API key. A private submodule needs no extra credentials when the person cloning can read it.
In the browser
The file list shows a submodule with the commit it is pinned to, such as lib @ 3f78685, and its URL from .gitmodules on hover. The name links to:
- the repository at that commit, when the URL points at the same Ghost instance over HTTPS, SSH or a relative path;
- the repository at that commit on a host Ghost knows the page layout of: GitHub, GitLab and the GitLab instances of Debian, GNOME, freedesktop.org, Arch Linux, KDE and Framasoft, Codeberg, git.gay, Gitea, Disroot, Bitbucket, sourcehut and Gitee;
- the repository's page on any other host. An SSH or
git://URL is opened over HTTPS on the same host, without its port.
Links to other sites open in a new tab. A URL that names no host, such as a path on the cloning machine, is shown without a link.
A commit or pull request that moves a submodule shows the change as Subproject commit 3f78685…9a1b2c3, or as added or removed, instead of a file diff.
What leaves submodules out
A submodule's files belong to its own repository, so the superproject does not count them anywhere:
- Source archives (
.zipand.tar.gz) contain an empty folder in place of each submodule, asgit archivewrites them. - Language statistics and code search cover the superproject's own files.
- The file finder lists files only, so it does not show submodules.