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

It is seying that I cannot do this:

 git submodule add -f libs/OAuth/functions

Because of this:

  • Git: Show list of commits during interactive rebase
  • git checkout and git status both say I am up-to-date, but then git pull pulls changes
  • Using LESS and Version Control: Should generated CSS be included in a repo?
  • Is there in git “git pull --dry-run” option?
  • git - only fetch the files, not the history
  • git create patch with diff
  • ‘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.

  • git push is very slow for a branch
  • adding android project to git
  • One-to-one mapping of git commits to TFS changesets using git-tfs rcheckin
  • Git-Bash Command Prompt won't open up after upgrading to Windows 10
  • Merge two git repositories into one, keeping (renamed) master branches
  • Revert a single change in a file in Git
  • 2 Solutions collect form web for “Error with git: “ already exists and is not a valid git repo””

    Even if the folder doesn’t exist, check the index status:

    cd libs/OAuth
    git ls-files -- functions

    If there is an entry registered in the index, you will need to remove it before being able to add your subrepos as a submodule.
    (as explained in “Issue with adding common code as git submodule: “already exists in the index””)

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

    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

    Git Baby is a git and github fan, let's start git clone.