Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error with git: " already exists and is not a valid git repo"

Tags:

git

github

oauth

It is seying that I cannot do this:

 git submodule add -f [email protected]:thephpleague/oauth2-server.git libs/OAuth/functions

Because of this:

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

I just don't get it. It does not exists anywhere. Is there another git config file hidden on my computer that I don't know of or something? I tried deleting .git and pulling everything again that did not do anything. Any ideas?

I also tried this:

git ls-files --stage functions

When I was inside of 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.

like image 581
jnbdz Avatar asked Jul 07 '14 05:07

jnbdz


People also ask

How do I fix a non repository in git?

To do so, you need to navigate to the correct folder and then run the command git init , which will create a new empty Git repository or reinitialize an existing one.

What is not a valid git repository?

A Git command needs to be run on a specific repository, so this error typically occurs when a Git command is run in a directory that Git doesn't know about. In these cases, the fix is to make sure that you are both working in the correct folder and that you set up your repository right.


1 Answers

In case someone else had a similar case as mine and was struggling with this as I was because of a stupid reason:

Check if for any reason the file doesn't already exists (I had a failed git subomdule add previously)

So in the context of the question rm the file:

rm -rf libs/OAuth/functions

And then try to re add

like image 162
Panthro Avatar answered Sep 21 '22 01:09

Panthro