git submodule add致命的:不是一个Git仓库 [英] git submodule add fatal: Not a Git Repository

查看:349
本文介绍了git submodule add致命的:不是一个Git仓库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Git还是陌生的,所以我会尽力找到一些有关此问题的文档,但无济于事.

I am fairly new to Git and trying my best to find some documentation on this problem to no avail.

这是我的命令:

$ git submodule add https://github.com/joliver/EventStore.git externalsource/JOliverEventStore/ 

致命的:不是git存储库:../.git/modules/externalsource/JOliverEventStore 无法检出子模块"externalsource/JOliverEventStore"

fatal: Not a git repository: ../.git/modules/externalsource/JOliverEventStore Unable to checkout submodule 'externalsource/JOliverEventStore'

我在我的仓库的根目录中,并且目前没有/externalsource/JO liverEventStore/的目录.错误是关于我不了解的目录.

I am in my root of my repo and there is currently no directory for /externalsource/JO liverEventStore/. The error is talking about a directory that I have no knowledge of.

如果我将子模块这样添加到根目录中:

If I add the submodule to the root dir like this:

$ git submodule add https://github.com/joliver/EventStore.git JOliverEventStore 

我没问题,它在根目录中创建了文件夹.

I have no problem and it creates the folder in the root directory.

任何见识将不胜感激.

推荐答案

它可能取决于您使用的Git版本:此最近的线程(2012年2月)提到了一个错误:

It can depends on the version of Git you are using: this recent thread (February 2012) mentions a bug:

自最近以来,名称为<name>的子模块的git目录位于超级项目的.git/modules/<name>目录中,而工作树包含指向该目录的gitfile.

Since recently a submodule with name <name> has its git directory in the .git/modules/<name> directory of the superproject while the work tree contains a gitfile pointing there.

在同一子模块上添加了到目前为止尚不存在的子模块(在.gitmodules文件中找不到)时,该名称未从路径中初始化.
找到.git/modules/<name>目录时,这会导致在gitfile中输入错误的路径,因为它很高兴使用-现在为空的名称.
这样,即使我们在目录层次结构中有更深的路径,它也始终仅指向单个目录.

When the same submodule is added on a branch where it wasn't present so far (it is not found in the .gitmodules file), the name is not initialized from the path as it should.
This leads to a wrong path entered in the gitfile when the .git/modules/<name> directory is found, as this happily uses the - now empty - name.
It then always points only a single directory up, even if we have a path deeper in the directory hierarchy.

但更普遍的是,使用 git submodule <path>参数>:

But more generally, uses the <path> argument of git submodule:

<path>是克隆的子模块在超级项目中存在的相对位置.

<path> is the relative location for the cloned submodule to exist in the superproject.

  • 如果<path>不存在,则通过从命名URL进行克隆来创建子模块.
  • 如果<path>确实存在并且已经是有效的git存储库,则将其添加到更改集中而不进行克隆.
    提供第二种形式是为了简化从头开始创建新的子模块的过程,并假定用户稍后将子模块推入给定的URL.
  • If <path> does not exist, then the submodule is created by cloning from the named URL.
  • If <path> does exist and is already a valid git repository, then this is added to the changeset without cloning.
    This second form is provided to ease creating a new submodule from scratch, and presumes the user will later push the submodule to the given URL.


eoinoc 提到 git status返回fatal: Not a git repository but .git exists and HEAD has proper permissions ".


eoinoc mentions in the comments another cause, which is detailed in the question "git status returns fatal: Not a git repository but .git exists and HEAD has proper permissions".

我的仓库的位置已更改,我需要更新git的配置文件.

My repo's location had changed, and I needed to update git's configuration files.

这篇关于git submodule add致命的:不是一个Git仓库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆