`--name` 选项不适用于 `git submodule add` 命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26215625/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
`--name` option doesn't work with `git submodule add` command
提问by ironsand
I want to add a git submodule with different name like:
我想添加一个具有不同名称的 git 子模块,例如:
git submodule add --name foo [email protected]:ironsand/cookbook-foo.git
I wanted to create a git submodule directory named foo
, but the repository are created with the name cookbook-foo
.
我想创建一个名为 的 git 子模块目录foo
,但存储库是使用名称创建的cookbook-foo
。
Most likely I'm doing something wrong, but I don't know what was wrong.
很可能我做错了什么,但我不知道出了什么问题。
How can I change the name of git submodule directory?
如何更改 git 子模块目录的名称?
回答by jub0bs
Don't conflate the pathand the nameof a submodule. You want to run
不要混淆子模块的路径和名称。你想跑
git submodule add [email protected]:ironsand/cookbook-foo.git foo/
instead. For more details, see the git-submodule
man page; the relevant git-submodule
syntax here is
反而。有关更多详细信息,请参阅git-submodule
手册页;git-submodule
这里的相关语法是
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>
.
<repository>
是新子模块的原始存储库的 URL。<path>
,如果指定,则确定子目录(超级项目的根目录)的名称以接收位于 的 repo 的克隆<repository>
;如果未指定,则<path>
默认为该存储库的名称。<name>
是子模块的名称,即出现在.gitmodules
文件中相应子模块条目中的名称;如果未指定,则<name>
默认为<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
回答by velaskec
Now it is supported by AWS CodeBuild OOB https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codebuild-project-gitsubmodulesconfig.html
现在它由 AWS CodeBuild OOB https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codebuild-project-gitsubmodulesconfig.html支持