* Adding existing repo at sub-sub-directory as submodule
@ 2022-09-15 10:49 Jonas Schulze
0 siblings, 0 replies; only message in thread
From: Jonas Schulze @ 2022-09-15 10:49 UTC (permalink / raw)
To: git
Hi everyone!
Is the following a bug? I am working with git v2.25.1. I hope I won't annoy anyone with a duplicate of an existing/known issue. I'm new to working with mailing lists as well.
# Problem Description
I would eventually like to add a submodule to `extern/foo` that is checked out at a particular tag. As I cannot `git clone`/`git submodule add` that tag directly, I have to first checkout the default and then check out the desired tag. If I do so from the repo's base directory, everything works as expected:
```bash
git clone <URL> foo
pushd foo
git checkout v1.1.1
popd
git submodule add ./foo
```
where the last one prints
```
Adding existing repo at 'foo' to the index
```
If, however, I do so with a target directory one level below, i.e. `./extern/foo` instead of `./foo`,
```bash
git submodule add ./extern/foo
```
tries to clone `<current remote URL.git>/extern/foo` into `./foo` and fails:
```
Cloning into '/path/to/repo/foo'...
remote:
remote: ========================================================================
remote:
remote: The namespace you were looking for could not be found.
remote:
remote: ========================================================================
remote:
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
fatal: clone of '<current remote URL.git>/extern/foo' into submodule path '/path/to/repo/foo' failed
```
Using `git submodule add ./foo` from within `extern/` does not work either (`Relative path can only be used from the toplevel of the working tree`).
# Expected Behavior
Given the documentation `git submodule --help`, in particular the part of `add` where it says
> If <path> exists and is already a valid Git repository, then it is staged for commit without cloning.
I would expect the output
```
Adding existing repo at 'extern/foo' to the index
```
# Current Workaround
Adding the submodule first and then updating it works:
```
git submodule add <URL> extern/foo
pushd extern/foo
git checkout v1.1.1
popd
git add extern/foo
```
# Feature Request
It would be nice if I could do something like `git submodule add -t v1.1.1 <URL> extern/foo`.
Thanks in advance!
Jonas
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-09-15 10:49 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-15 10:49 Adding existing repo at sub-sub-directory as submodule Jonas Schulze
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).