简体   繁体   中英

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

I have a folder inside a git repository which should be its own repository.

I do not want to use the git submodules or whatever they provide.

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. 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.

What can I do to tell git to ignore the top one and pretend like its not there?

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. 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. 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 .

The latter wont work without git init

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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