Error with git: "git repo already exists and is invalid"

This means that I cannot do this:

git submodule add -f git@github.com :thephpleague/oauth2-server.git libs/OAuth/functions 

Because of this:

'libs / OAuth / functions' already exists and is not a valid git repo

I just do not understand. He does not exist anywhere. Is there another git configuration file hidden on my computer that I donโ€™t know about or something else? I tried removing .git and pulling everything that didn't do anything. Any ideas?

I also tried this:

 git ls-files --stage functions 

When I was inside libs / OAuth and I got nothing.

Then I tried this:

 sudo git rm --cached functions 

I got this error:

 fatal: pathspec 'functions' did not match any files 

I also tried this:

 sudo git rm -r --cached functions 

And got the same previous error.

+11
source share
2 answers

Even if the folder does not exist, check the status of the index:

 cd libs/OAuth git ls-files -- functions 

If there is an entry registered in the index, you will need to delete it before you can add your subppos as a submodule.
(as explained in The problem of adding generic code in the form of a git submodule: "already exists in the index" ")

All this assumes that you are in the root folder of the currently cloned repo, which will act as the parent repo of any submodule that you declare.

+2
source

In case someone had the same case as mine, and he struggled with this, as I did, for a stupid reason:

Check if the file exists for any reason (previously I could not add the git submodule)

So, in the context of the question rm file:

 rm -rf libs/OAuth/functions 

And then try adding again

+8
source

Source: https://habr.com/ru/post/971845/


All Articles