Adding existing repo at sub-sub-directory as submodule

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux