'Git submodule failure when building pages with Hugo

I am trying to follow the steps on Deployment as described in the manual of Academic-Hugo. The goal is to upload the Hugo website to GitHub pages. However the following step fails and I have no clue what the issue could be:

$ git submodule add -f -b master https://github.com/<USERNAME>/<USERNAME>.github.io.git public
Reactivating local git directory for submodule 'public'.
fatal: 'origin/master' is not a commit and a branch 'master' cannot be created from it
Unable to checkout submodule 'public'

The .gitmodules file looks like this (not sure how relevant that is though...):

[submodule "themes/academic"]
    path = themes/academic
    url = https://github.com/gcushen/hugo-academic.git
[submodule "public"]
    path = public
    url = https://github.com/<USERNAME>/<USERNAME>.github.io.git
    branch = master

While <USERNAME> is my actual username of course. I am new to Hugo and github pages and would appreciate any pointers on how to resolve this or even where to look for the root of the issue.



Solution 1:[1]

I had the same issue. I tried to continue on anyway and it ended up working:

site $ hugo
site $ cd public/
site/public $ git add .
site/public $ git commit -m "initial build"
site/public $ git push # After this, all is well.

I did run a git status prior to pushing, but it had a warning (don't recall the message) and suggested I remove the remote origin. I ignored that too.

Solution 2:[2]

Had the same issue today and landed on this site that has some useful info about deleting modules and re-doing the whole thing from start. Hope it might be useful to others as well.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Nick
Solution 2 Kirk Walla