Dzx
Dzx

Reputation: 61

Failing to deploy website on Netlify when trying to use alternate hexo theme

·Trying "git clone" lead to the following message when deploying:

failed during stage 'preparing repo': Error checking out submodules:fatal: No url found for submodule path 'themes/ocean' in .gitmodules

·Trying "git submodule add" lead to the following:

failed during stage 'building site': Deploy directory 'public/' does not exist

A temporary solution seems to be removing the .git folder within the theme,but is there any better choice?

Upvotes: 4

Views: 8363

Answers (2)

Anantha Raju C
Anantha Raju C

Reputation: 1907

This occurs when the repository is using files cloned from another repository, but has had no mapping reference to the source repository created for it. The mapping needs to be added to a .gitmodules file located in the root directory of the repository you are using.

To create the mapping reference, enter the following into your .gitmodules file:

[submodule "path_to_submodule"] 
  path = path_to_submodule 
  url = git://url-of-source/

Where path_to_submodule is the actual path within your repository (relative to the root directory) where the submodule will be used, and url-of-source is the URL of the original repository that contains the submodule's files.

In the case that you might wish to remove an unwanted submodule from your repository, run the following command in your local repository, then push the change to the remote:

git rm --cached path_to_submodule

Where path_to_submodule is the path to your submodule.

Reference: https://www.deployhq.com/support/common-repository-errors/no-url-found-for-submodule

Upvotes: 4

VonC
VonC

Reputation: 1329812

Note that Netlify's CI will consider any subdirectory having a .git/ sub-subdirectory in it to be a submodule and attempt to update it with the git submodule update command, and this will fail if you have not configured the submodule intentionally (instead just git cloneing another repo into your repo as you have likely done).

Assuming you have a submodule setup properly already (See this article for details), you could try to see what URL is referenced in the .gitmodules at the root folder of your local repo.

If you have control over the repo you want to deploy on netlify, you could first clone it locally, update the URL of the submodule with one that works, push, and then deploy the newly update repo.

Upvotes: 0

Related Questions