OGIOS

personal website.


Table of contents

Using Git Submodules

This website is a great example: ogios.github.io

  • blogs are in another repo, and it's been added as a submodule under /contents/blogs, blgos has it's own scripts and metadata.
  • Multiple separated frontend projects are added as submodules under /projects, they all provide a build cmd: build:submodule , dist will be moved to /.output/public.

Warning

Git submodules is not fully bind with branches, but file .gitmodules does.
This may be confusing, for example:

  • checkout from a branch with submodules to a branch without submodules, the submodule will not disappear, you have to delete it manually.
  • checkout from a branch without submodules to a branch with submodules, git will not initialize the module itself, it's manually done.
  • both branch can have there own submodules recorded in .gitmodules, module's directory will be created but modules won't be initialized.

Usage

Note

it's recommended to use GUI or TUI.
I personally use lazygit for every git related operations, it's a TUI project and enough for normal use.

Add a submodule:

git submodule add <url> <path>

Remove a submodule:

git rm --force -r <path>

Update from upstream:

git submodule update --remote --recursive [ -- <path>]

Init submodule:

git submodule update --init --force [ -- <path>]

Other

You should not be afraid of deleting anything under a submodule.
/.gitmodules records every submodule's path and with git submodule update --init --force it will be recovered.