`–name` option doesn’t work with `git submodule add` command

Don’t conflate the path and the name of a submodule. You want to run

git submodule add git@bitbucket.org:ironsand/cookbook-foo.git foo/

instead. For more details, see the git-submodule man page; the relevant git-submodule syntax here is

git submodule [--name <name>] <repository> [<path>]

where…

  • <repository> is the URL of the new submodule’s origin repository.
  • <path>, if specified, determines the name of the subdirectory (of the superproject’s root directory) to receive the clone of the repo living at <repository>; if left unspecified, <path> defaults to the name of that repo.
  • <name> is the submodule’s name, i.e. the name that appear in the corresponding submodule entry in the .gitmodules file; if left unspecified, <name> simply defaults to <path>.

Here is a toy example to fix ideas:

$ cd ~/Desktop
$ mkdir test
$ cd test
$ git init
$ git submodule add --name brutus https://github.com/bradfitz/gitbrute bradfitz_bruteforce
$ ls -a
.           .git            bradfitz_bruteforce
..          .gitmodules
$ cat .gitmodules
[submodule "brutus"]
    path = bradfitz_bruteforce
    url = https://github.com/bradfitz/gitbrute

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)