我正在尝试向我的 git 存储库添加一个子模块,但我得到了这个错误:
remote origin does not have a url defined in .git/config
关于这可能是什么的任何想法?我尝试用谷歌搜索它,但只出现一个模糊的链接。
我这样做:
git submodule add ../extern/Lib1 lib
我希望这会创建一个子模块 lib/Lib1
我知道这只会创建一个引用,然后我必须更新/初始化(这部分不是很清楚,还没有走那么远;我只是在学习子模块命令)。
最佳答案
是否 ../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/*
...
如果您在 ../DirName/NewRepo_withSubmodules/.git/config 中确实有该部分文件,你应该能够添加 ../Extern/Lib1作为使用相对路径的子模块。
以上所有内容均来自 git submodule 手册页的以下部分:
<repository>is the URL of the new submodule's origin repository.
This may be either an absolute URL, or (if it begins with./or../), the location relative to the superproject'soriginrepository.
所以如果NewRepo_withSubmodules是刚刚创建的本地 Git 存储库(当然没有“来源”),应该定义一个人为的“远程来源”(即使来源指向自身),如果只是为了允许其他子模块的相对 url要使用的存储库。
Git 2.13(2017 年第 2 季度)将改进对子模块默认来源的检测。
参见 commit d1b3b81 (2017 年 2 月 25 日)Stefan Beller ( stefanbeller ) .
(由 Junio C Hamano -- gitster -- merge 于 commit ae900eb ,2017 年 3 月 10 日)
submodule init: warn about falling back to a local path
作为now documented :
<repository>is the URL of the new submodule's origin repository.
This may be either an absolute URL, or (if it begins with./or../), the location relative to the superproject's default remote repository
(Please note that to specify a repository 'foo.git' which is located right next to a superproject 'bar.git', you'll have to use '../foo.git' instead of './foo.git' - as one might expect when following the rules for relative URLs - because the evaluation of relative URLs in Git is identical to that of relative directories).
The default remote is the remote of the remote tracking branch of the current branch.
If no such remote tracking branch exists or theHEADis detached, "origin" is assumed to be the default remote.
If the superproject doesn't have a default remote configured the superproject is its own authoritative upstream and the current. working directory is used instead.
Git 2.20(2018 年第 4 季度)改进了对子模块的本地路径支持。
参见 commit e0a862f (2018 年 10 月 16 日)Stefan Beller ( stefanbeller ) .
(由 Junio C Hamano -- gitster -- merge 于 commit 3fc8522 ,2018 年 11 月 6 日)
submodule helper: convert relative URL to absolute URL if needed
The submodule helper
update_clonecalled by "git submodule update", clones submodules if needed.
As submodules used to have the URL indicating if they were active, the step to resolve relative URLs was done in the "submodule init" step. Nowadays submodules can be configured active without calling an explicit init, e.g. via configuringsubmodule.active.
When trying to obtain submodules that are set active this way, we'll fallback to the URL found in the
.gitmodules, which may be relative to the superproject, but we do not resolve it, yet:
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
[...]
To resolve the issue, factor out the function that resolves the relative URLs in "
git submodule init" (in the submodule helper in theinit_submodulefunction) and call it at the appropriate place in theupdate_clonehelper.
关于git - 指定为相对路径时无法添加 git 子模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1974181/
当我使用Bundler时,是否需要在我的Gemfile中将其列为依赖项?毕竟,我的代码中有些地方需要它。例如,当我进行Bundler设置时:require"bundler/setup" 最佳答案 没有。您可以尝试,但首先您必须用鞋带将自己抬离地面。 关于ruby-我需要将Bundler本身添加到Gemfile中吗?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/4758609/
我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-
我对最新版本的Rails有疑问。我创建了一个新应用程序(railsnewMyProject),但我没有脚本/生成,只有脚本/rails,当我输入ruby./script/railsgeneratepluginmy_plugin"Couldnotfindgeneratorplugin.".你知道如何生成插件模板吗?没有这个命令可以创建插件吗?PS:我正在使用Rails3.2.1和ruby1.8.7[universal-darwin11.0] 最佳答案 随着Rails3.2.0的发布,插件生成器已经被移除。查看变更日志here.现在
我有一个ModularSinatra应用程序,我正在尝试将Bootstrap添加到应用程序中。get'/bootstrap/application.css'doless:"bootstrap/bootstrap"end我在views/bootstrap中有所有less文件,包括bootstrap.less。我收到这个错误:Less::ParseErrorat/bootstrap/application.css'reset.less'wasn'tfound.Bootstrap.less的第一行是://CSSReset@import"reset.less";我尝试了所有不同的路径格式,但它
我尝试运行2.x应用程序。我使用rvm并为此应用程序设置其他版本的ruby:$rvmuseree-1.8.7-head我尝试运行服务器,然后出现很多错误:$script/serverNOTE:Gem.source_indexisdeprecated,useSpecification.Itwillberemovedonorafter2011-11-01.Gem.source_indexcalledfrom/Users/serg/rails_projects_terminal/work_proj/spohelp/config/../vendor/rails/railties/lib/r
我正在尝试在我的centos服务器上安装therubyracer,但遇到了麻烦。$geminstalltherubyracerBuildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingtherubyracer:ERROR:Failedtobuildgemnativeextension./usr/local/rvm/rubies/ruby-1.9.3-p125/bin/rubyextconf.rbcheckingformain()in-lpthread...yescheckingforv8.h...no***e
我正在使用Sequel构建一个愿望list系统。我有一个wishlists和itemstable和一个items_wishlists连接表(该名称是续集选择的名称)。items_wishlists表还有一个用于facebookid的额外列(因此我可以存储opengraph操作),这是一个NOTNULL列。我还有Wishlist和Item具有续集many_to_many关联的模型已建立。Wishlist类也有:selectmany_to_many关联的选项设置为select:[:items.*,:items_wishlists__facebook_action_id].有没有一种方法可以
我花了三天的时间用头撞墙,试图弄清楚为什么简单的“rake”不能通过我的规范文件。如果您遇到这种情况:任何文件夹路径中都不要有空格!。严重地。事实上,从现在开始,您命名的任何内容都没有空格。这是我的控制台输出:(在/Users/*****/Desktop/LearningRuby/learn_ruby)$rake/Users/*******/Desktop/LearningRuby/learn_ruby/00_hello/hello_spec.rb:116:in`require':cannotloadsuchfile--hello(LoadError) 最佳
我在pry中定义了一个函数:to_s,但我无法调用它。这个方法去哪里了,怎么调用?pry(main)>defto_spry(main)*'hello'pry(main)*endpry(main)>to_s=>"main"我的ruby版本是2.1.2看了一些答案和搜索后,我认为我得到了正确的答案:这个方法用在什么地方?在irb或pry中定义方法时,会转到Object.instance_methods[1]pry(main)>defto_s[1]pry(main)*'hello'[1]pry(main)*end=>:to_s[2]pry(main)>defhello[2]pry(main)
我使用的是Firefox版本36.0.1和Selenium-Webdrivergem版本2.45.0。我能够创建Firefox实例,但无法使用脚本继续进行进一步的操作无法在60秒内获得稳定的Firefox连接(127.0.0.1:7055)错误。有人能帮帮我吗? 最佳答案 我遇到了同样的问题。降级到firefoxv33后一切正常。您可以找到旧版本here 关于ruby-无法在60秒内获得稳定的Firefox连接(127.0.0.1:7055),我们在StackOverflow上找到一个类