简体   繁体   English

嵌套git存储库文件夹“致命:远程来源已经存在”

[英]“fatal: remote origin already exists” with nested git repository folders

I have a folder inside a git repository which should be its own repository. 我在git存储库中有一个文件夹,应该是它自己的存储库。

I do not want to use the git submodules or whatever they provide. 我不想使用git子模块或它们提供的任何东西。

I have done this multiple times before and it always worked but now there seems to be something wrong. 我之前已经做过多次,并且一直都有效,但是现在似乎出了点问题。

Inside the nested folder I do this: 在嵌套文件夹中,我这样做:

git remote add origin https://bitbucket.org/team/repo

and I get this: 我得到这个:

fatal: remote origin already exists.

I think whats happening is that it recognised the git repository thats one folder above and therefore isnt allowing me to set one up in it. 我认为发生的事情是它识别出git存储库即上面的一个文件夹,因此不允许我在其中建立一个。 But I KNOW that I have done this before and its working with the other folders. 但是我知道我之前已经做过,并且可以和其他文件夹一起使用。 When I do "git status" in the working ones I get a status that shows the sub repo and not the overlying one. 当我在工作状态中执行“ git status”时,我得到的状态显示的是子仓库,而不是上面的子仓库。

What can I do to tell git to ignore the top one and pretend like its not there? 我该怎么做才能告诉git忽略最上面的那个,并假装它不在那里?

EDIT: Here is what DOES work: 编辑:这是起作用的:

Instead of creating the folder and doing git remote add origin ... I straight away just clone the existing repo. 而不是创建文件夹并执行git remote add origin ...我直接克隆了现有的仓库。 Then I end up with a working subfolder with its own origin. 然后,我得到了一个具有自己来源的工作子文件夹。 (Am I already using submodules now or is this in fact a work around?) (我现在是否已经在使用子模块,或者这实际上是可以解决的?)

EDIT2: This question is about HOW to solve the nesting problem. EDIT2:这个问题是关于如何解决嵌套问题的。 The possible duplicate however is about WHY the solution found in the anwsers works the way it does. 但是,可能的重复是关于为什么在锚定器中找到的解决方案以其工作方式工作的原因。

The solution to having nested repo's like I described is either just cloning the wanted repo inside the other or creating the folder, navigating inside and running both git init as well as git remote add origin . 像我描述的那样,使用嵌套的repo的解决方案是要么在另一个仓库中克隆所需的repo, 要么创建文件夹,在其中导航并运行git initgit remote add origin

The latter wont work without git init 没有git init后者将无法工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM