Git:带有前导减号的子模块

时间:2012-05-18 11:01:05

标签: git msysgit

我需要创建一个带有前导减号的子模块,因此使用msysgit 1.7.10执行以下命令:

mike@desktop /c/temp/git/repo1 (master)
$ git submodule add -- ../repo2 "- submodule"
The following path is ignored by one of your .gitignore files:
- submodule
Use -f if you really want to add it.

好的,然后我尝试使用force-option:

mike@desktop /c/temp/git/repo1 (master)
$ git submodule add -f -- ../repo2 "- submodule"
error: unknown switch ` '
usage: git clone [options] [--] <repo> [<dir>]

    -v, --verbose         be more verbose
    -q, --quiet           be more quiet
    --progress            force progress reporting
    -n, --no-checkout     don't create a checkout
    --bare                create a bare repository
    --mirror              create a mirror repository (implies bare)
    -l, --local           to clone from a local repository
    --no-hardlinks        don't use local hardlinks, always copy
    -s, --shared          setup as shared repository
    --recursive           initialize submodules in the clone
    --recurse-submodules  initialize submodules in the clone
    --template <template-directory>
                          directory from which templates will be used
    --reference <repo>    reference repository
    -o, --origin <name>   use <name> instead of 'origin' to track upstream
    -b, --branch <branch>
                          checkout <branch> instead of the remote's HEAD
    -u, --upload-pack <path>
                          path to git-upload-pack on the remote
    --depth <depth>       create a shallow clone of that depth
    --single-branch       clone only one branch, HEAD or --branch
    --separate-git-dir <gitdir>
                          separate git dir from working tree
    -c, --config <key=value>
                          set config inside the new repository

Clone of 'c:/temp/git/repo2' into submodule path '- submodule' failed

奇怪,我调用了git submodule' and get an error about git clone`。

1 个答案:

答案 0 :(得分:2)

这看起来像git-submodule.sh中的错误 - 它调用:

git add $force "$sm_path"

...显然会因- submodule之类的路径而失败。它必须是:

git add $force -- "$sm_path"

......相反。如果子模块路径看起来像一个选项,git-submodule.sh中还有其他几个地方也会失败,所以修复并不简单。

我强烈建议您不要尝试使用以-开头的子模块路径。