如何重命名git子模块



我创建了一个子模块来显示我在github网站上为我的类(课程类而非代码类(所做的代码。

我做的第一堂课是学习HTML编程,所以我为它制作了一个存储库。然后我创建了一个子模块,将代码与网站链接起来。这很有效。然后我开始下一节课,CSS。

然后我想,我将把所有的类分组在一个存储库下,而不是几个存储库(和子模块(。问题是,当我创建子模块时,它从某个地方取了一个名字,我从未明确指定过一个。它取了一个名字";ltp-html5-授权";并将其附加在所有内容之前。对于第一类的链接来说,这看起来并不算太糟,ltp-html5-授权/ltp-html5-授权/ltpa-html5-权限.html但第二个是完全错误的。ltp-html5-授权/ltp-cs3-specialist/ltp-css3-specialist.html并且在我添加文件夹时将继续出错。

有没有办法重命名子模块,或者我必须删除它并重新添加它?

git mv

不起作用,因为子模块的名称不作为任何文件夹的一部分存在。该名称以子模块的url为前缀,因此成为

我发布:

C:Codesite>git submodule foreach -q git config remote.origin.url
https://github.com/Marvelous-Software/ltp-html5-authoring.git

我试过了:

C:Codesite>git submodule set-url ltp-html5-authoring https://github.com/Marvelous-Software/Frameworktv.git

C:Codesite>git submodule set-url https://github.com/Marvelous-Software/ltp-html5-authoring https://github.com/Marvelous-Software/Frameworktv

虽然我没想到会这样,因为参数set url不是我想要做的,而且它无论如何都不起作用。

路径在哪里https://github.com/Marvelous-Software/Frameworktv.git登录页的路径是https://marvelous-software.github.io/school/ltp-html5-authoring/ltp-html5-authoring/ltp-html5-authoring.htmlwhish是

很遗憾,我无法确定是否可以重命名子模块。在测试时,我试图创建一个新的子模块,使用以下命令显式设置名称:

git submodule add https://github.com/Marvelous-Software/FrameworkTelevision.git --name Frameworktv

我在此基础上使用了--name参数:

C:Codesite>git submodule -?
usage: git submodule [--quiet] [--cached]
or: **git submodule [--quiet] add [-b <branch>] [-f|--force] [--name <name>]** [--reference <repository>] [--] <repository> [<path>]
or: git submodule [--quiet] status [--cached] [--recursive] [--] [<path>...]
or: git submodule [--quiet] init [--] [<path>...]
or: git submodule [--quiet] deinit [-f|--force] (--all| [--] <path>...)
or: git submodule [--quiet] update [--init] [--remote] [-N|--no-fetch] [-f|--force] [--checkout|--merge|--rebase] [--[no-]recommend-shallow] [--reference <repository>] [--recursive] [--[no-]single-branch] [--] [<path>...]
or: git submodule [--quiet] set-branch (--default|--branch <branch>) [--] <path>
or: git submodule [--quiet] set-url [--] <path> <newurl>
or: git submodule [--quiet] summary [--cached|--files] [--summary-limit <n>] [commit] [--] [<path>...]
or: git submodule [--quiet] foreach [--recursive] <command>
or: git submodule [--quiet] sync [--recursive] [--] [<path>...]
or: git submodule [--quiet] absorbgitdirs [--] [<path>...]

这创建了一个子模块,名为--name

好吧,现在我有一个烂摊子要清理,git命令不能使用--name作为名称,因为它被解释为一个参数。所以我删除了父文件夹中的链接文件夹。我删除了.git/modules中的子模块文件夹。然后删除了.gt/config中的条目,我在其中找到了name。也许我一开始就可以更改那里的名称,在删除原始子模块之前我没有检查配置文件。

但在我清理完所有内容后,我用以下命令创建了一个名为Frameworktv的新子模块:

git submodule add https://github.com/Marvelous-Software/FrameworkTelevision.git Frameworktv

而且效果非常好!

https://marvelous-software.github.io/Frameworktv/ltp-html5-authoring/ltp-html5-authoring.html

配置中的代码:

[submodule "Frameworktv"]
url = https://github.com/Marvelous-Software/FrameworkTelevision.git
active = true

首先检查主存储库.gitmodules的内容:ltp-html5-authoring应该是与每个子模块关联的路径的一部分。

如果路径错误,您可以(最好使用Git 2.18或更高版本(使用git mv来移动子模块。

git mv  ltp-html5-authoring/ltp-css3-specialist anotherPrefix/ltp-css3-specialist 

最新更新