dee*_*lue 35 git git-submodules
我正在尝试向我的git repo添加一个子模块,我收到了这个错误:
remote origin does not have a url defined in .git/config
Run Code Online (Sandbox Code Playgroud)
关于这可能是什么的任何想法?我试着谷歌搜索它,但只有一个模糊的链接出现.
我这样做:
git submodule add ../extern/Lib1 lib
Run Code Online (Sandbox Code Playgroud)
我期待这个创建一个子模块lib/Lib1
我知道这只会创建一个引用,然后我必须更新/ init(在这部分不是很清楚,没有那么远;我只是在学习子模块命令).
Von*_*onC 30
是否../extern/Lib1引用Git存储库?
如果没有,Git将不知道如何将Git repo url添加到其中..gitmodule
另外,尝试:
lib 不是已经存在的(即使是空)子模块的一些好的来源是:
由于此处只有绝对路径,因此相对路径需要与之进行比较.
该引用是应该在您的DirName/NewRepo_withSubmodules/.git/config文件中的"远程源" ,如下所示:
$ cat .git/config
...
[remote "origin"]
url = /path/to/DirName/NewRepo_withSubmodules/.git
fetch = +refs/heads/*:refs/remotes/origin/*
...
Run Code Online (Sandbox Code Playgroud)
如果../DirName/NewRepo_withSubmodules/.git/config文件中有该部分,则应该能够../Extern/Lib1使用相对路径添加为子模块.
以上所有内容都来自git子模块手册页的以下部分:
<repository>是新子模块的原始存储库的URL.
这可以是绝对URL,或者(如果以./或开头../),相对于超级项目的origin存储库的位置.
因此,如果NewRepo_withSubmodules是刚刚创建的本地Git仓库(并且当然没有"原点"),则应该定义一个人为的"远程原点"(即使原点指向自身),如果只是为了允许相对URL要使用的其他子模块存储库.
Git 2.13(2017年第二季度)将改进子模块默认原点的检测.
请参阅Stefan Beller()提交d1b3b81(2017年2月25日).(由Junio C Hamano合并- -在2017年3月10日的提交ae900eb中)stefanbeller
gitster
submodule init:警告要回到当地的道路上
如现在记录:
<repository>是新子模块的原始存储库的URL.
这可以是绝对URL,或者(如果它以./或开头../),相对于超级项目的默认远程存储库的位置
(请注意,要指定一个foo.git位于超级项目旁边的存储库'bar.git',你将会必须使用"../foo.git而不是./foo.git" - 正如人们在遵循相对URL规则时所期望的那样 - 因为Git中相对URL的评估与相对目录的相同.默认远程是当前分支的远程跟踪分支的远程.
如果不存在这样的远程跟踪分支或HEAD分离,origin则假定" "是默认远程.
如果超级项目没有配置默认远程,则超级项目是其自己的权威上游和当前.改为使用工作目录.
Git 2.20(Q8 2018)改进了子模块的本地路径支持.
参见Stefan Beller()提交e0a862f(2018年10月16日).(由Junio C Hamano合并- -在提交3fc8522,2018年11月6日)stefanbeller
gitster
submodule helper:如果需要,将相对URL转换为绝对URL
update_clone由"git submodule update" 调用的子模块助手,如果需要,克隆子模块.
由于子模块用于指示URL是否处于活动状态,因此解决相对URL的步骤在"submodule init"步骤中完成.现在,可以将子模块配置为活动状态,而无需调用显式init,例如通过配置submodule.active.当尝试获取以这种方式设置为活动的子模块时,我们将回
.gitmodules退到可能相对于超级项目的URL中找到的URL ,但是我们还没有解决它:Run Code Online (Sandbox Code Playgroud)git clone https://gerrit.googlesource.com/gerrit cd gerrit && grep url .gitmodules url = ../plugins/codemirror-editor ... git config submodule.active . git submodule update fatal: repository '../plugins/codemirror-editor' does not exist fatal: clone of '../plugins/codemirror-editor' into submodule path '/tmp/gerrit/plugins/codemirror-editor' failed Failed to clone 'plugins/codemirror-editor'. Retry scheduled [...] fatal: clone of '../plugins/codemirror-editor' into submodule path '/tmp/gerrit/plugins/codemirror-editor' failed Failed to clone 'plugins/codemirror-editor' a second time, aborting [...]要解决此问题,请将解析相对URL的函数分解为"
git submodule init"(在init_submodule函数的子模块帮助程序中),并在update_clone帮助程序中的适当位置调用它.
小智 5
我正在尝试同样的事情,发现以下“似乎有效”:
我有(在Windows上):
D:/phd/analyses
/analysis1/ #This is an existing repository
/analysis2/ #another existing repository
/analysis3.tex
/analysis4.tex
...
/analysisN.tex
Run Code Online (Sandbox Code Playgroud)
analysis1.tex ... analysisN.tex包含我还没有研究过的想法(比如存根),并且analysis1/是analysis2/我正在研究的东西(因此其中有代码,tex,...)。一旦我开始进行其他分析,它们就会被移动到自己的文件夹,从而移动到自己的存储库。
我所做的是(在 git bash 分析中):
git init
git add *.tex
git remote add self .
git submodule add self:/analysis2/.git analysis2
git submodule add self:/analysis5/.git analysis5
git commit -m "Initial commit"
Run Code Online (Sandbox Code Playgroud)
这似乎奏效了。
D:/phd/analyses/.git/config看起来应该是这样,并且.gitmodules看起来像:
[submodule "analysis2"]
path = analysis2
url = self:analysis2/.git
[submodule "analysis5"]
path = analysis5
url = self:analysis5/.git
Run Code Online (Sandbox Code Playgroud)
问候, 西蒙·纳普
| 归档时间: |
|
| 查看次数: |
19442 次 |
| 最近记录: |