{"thread":{"id":"58434","subject":"Adding existing repo at sub-sub-directory as submodule","startedAt":"2022-09-15T10:49:34Z","lastAt":"2022-09-15T10:49:34Z","messageCount":1,"participants":["Jonas Schulze"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"463036","messageId":"1678038401.2138998.1663238966604.JavaMail.zimbra@mpi-magdeburg.mpg.de","threadId":"58434","inReplyTo":null,"subject":"Adding existing repo at sub-sub-directory as submodule","fromName":"Jonas Schulze","fromEmail":"jschulze@mpi-magdeburg.mpg.de","sentAt":"2022-09-15T10:49:26Z","receivedAt":"2022-09-15T10:49:34Z","isPatch":false,"sender":{"key":"jschulze@mpi-magdeburg.mpg.de","avatar":null},"body":"Hi everyone! \n\n\nIs 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. \n\n# Problem Description \n\nI 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: \n```bash \ngit clone <URL> foo \npushd foo \ngit checkout v1.1.1 \npopd \ngit submodule add ./foo \n``` \nwhere the last one prints \n``` \nAdding existing repo at 'foo' to the index \n``` \n\nIf, however, I do so with a target directory one level below, i.e. `./extern/foo` instead of `./foo`, \n```bash \ngit submodule add ./extern/foo \n``` \ntries to clone `<current remote URL.git>/extern/foo` into `./foo` and fails: \n``` \nCloning into '/path/to/repo/foo'... \nremote: \nremote: ======================================================================== \nremote: \nremote: The namespace you were looking for could not be found. \nremote: \nremote: ======================================================================== \nremote: \nfatal: Could not read from remote repository. \n\nPlease make sure you have the correct access rights \nand the repository exists. \nfatal: clone of '<current remote URL.git>/extern/foo' into submodule path '/path/to/repo/foo' failed \n``` \n\nUsing `git submodule add ./foo` from within `extern/` does not work either (`Relative path can only be used from the toplevel of the working tree`). \n\n# Expected Behavior \n\nGiven the documentation `git submodule --help`, in particular the part of `add` where it says \n\n> If <path> exists and is already a valid Git repository, then it is staged for commit without cloning. \n\nI would expect the output \n``` \nAdding existing repo at 'extern/foo' to the index \n``` \n\n# Current Workaround \n\nAdding the submodule first and then updating it works: \n``` \ngit submodule add <URL> extern/foo \npushd extern/foo \ngit checkout v1.1.1 \npopd \ngit add extern/foo \n``` \n\n# Feature Request \n\nIt would be nice if I could do something like `git submodule add -t v1.1.1 <URL> extern/foo`. \n\n\nThanks in advance! \n\nJonas\n"}]}