Search code examples
gitgithubgit-submodules

Unable to create git submodule - remote: Not Found


When creating a git submodule using git bash, I am getting below error

$ git submodule add  https://github.com/******/my-repo/my-app 
Cloning into 'D:/my-repo/my-app'...
remote: Not Found
fatal: repository 'https://github.com/*******/my-repo/my-app/' not found
fatal: clone of 'https://github.com/*******/my-repo/my-app' into submodule path 'D:/my-repo/my-app' failed

Below is my .git/config file

$ cat .git/config
[core]
        repositoryformatversion = 0
        filemode = false
        bare = false
        logallrefupdates = true
        symlinks = false
        ignorecase = true
[remote "origin"]
        url = https://github.com/*******/my-repo.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master

I was able to clone my-repo from github, but when I try to add a submodule after cloning, I am seeing this error. Should I create a repo for my-app submodule separately in github to be able to add it as a submodule in another repo (my-repo) ?

Or, am I missing any configuration here ?

PS: I was following this link - https://git-scm.com/book/en/v2/Git-Tools-Submodules


Solution

  • Should I create a repo for my-app submodule separately in github to be able to add it as a submodule in another repo (my-repo)

    Yes.

    https://github.com/******/my-repo/my-app is not the URL of a Git repo to be cloned.
    It is the URL of a subfolder of an existing repository (namely: https://github.com/*******/my-repo.git).

    Having myapp in its own repository is a prerequisite to being able to add it as a submodule to another repo.