basickarl
basickarl

Reputation: 40524

adding local .git via submodule failing

File structure:

www
 |- project
     |- .git
 |- dist
     |- .git

And the terminal:

karl@karl-laptop:~/www/project$ git submodule add ../dist dist
Cloning into 'dist'...
conq: repository does not exist.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Clone of '[email protected]:user/dist' into submodule path 'dist' failed

I'm having a hard time finding how to use submodule on local repos! As you can see it wants to clone from git@bitbucket, but I want it to clone from a local repo.

I normally use ssh to push to bitbucket.

Upvotes: 1

Views: 90

Answers (2)

Michael F
Michael F

Reputation: 1409

The git documentation says:

git submodule add repository [path]

repository is the URL of the new submodule’s origin repository. This may be either an absolute URL, or (if it begins with ./ or ../), the location relative to the superproject’s origin repository.

You need to specify an absolute file path if you want to clone from your file system. If you give ./ or ../ (as you do) it will attempt to fetch from the origin of the superproject, which is bitbucket.org in your case.

Upvotes: 1

larsks
larsks

Reputation: 312048

The parameters to git submodule add are <repository> and <path>, where <repository> is a reference to a "remote" repository and <path> is the relative path inside your current repository at which to install the submodule.

For example, if I am working in a directory project1 that is a git repository and I want to add ../project2 as a submodule at lib/project2, I would run:

$ git submodule add ../project2 lib/project2
Cloning into 'lib/project2'...
done.

And now I can run git submodule to see the status of submodules:

$ git submodule
 2c1e66331909365e5c4d0f11659a1baeb863b3f0 lib/project2 (heads/master)

Upvotes: 0

Related Questions