Notes on Updating a Hugo Theme Managed as a Git Submodule

How to update submodule theme

* This page contains promotional content

On this site I manage the Hugo Beautifulhuigo theme as a submodule on Gitlab.

From time to time the upstream submodue theme gets updated, but git clone and git push do not update the submodule automatically
So it has to be updated by hand, and since this is work I do often, I am writing it down as a note

Cloning my own repository

$ git clone --recurse-submodules --depth 1 https://gitlab.com/user/repo.git
$ cd repo

Updating the submodule

The only thing you actually have to do is git submodule update --remote

$ git submodule status
 91a30c4f752864aaafa2ae2b633d022c8810a5e8 themes/mainroad (91a30c4)

$ git submodule update --remote
Submodule path 'themes/mainroad': checked out '10d59da42f7bca5e7bd9e0409509a608fdd84080'

$ git diff
diff --git a/themes/mainroad b/themes/mainroad
index 91a30c4..10d59da 160000
--- a/themes/mainroad
+++ b/themes/mainroad
@@ -1 +1 @@
-Subproject commit 91a30c4f752864aaafa2ae2b633d022c8810a5e8
+Subproject commit 10d59da42f7bca5e7bd9e0409509a608fdd84080

Applying the updated submodule

$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   themes/mainroad (new commits)

no changes added to commit (use "git add" and/or "git commit -a")

$ git add .
$ git commit -m "Update submodule"
$ git push

See also