Skip to content

VS Code not recognizing a git repo workspace #2947

Closed

Description

@stuartweir

The issue is that I open a project already initialized, I don't initialize in VS Code (for example, opening a cloned repo that I can git status on and shows me the info in regards to that), and yet VS Code shows: "This workspace isn't yet under git source control."

Step by Step:

  1. Open VS Code
  2. Open workspace already initialized with git.
  3. Click the Git icon on the side.
  4. Shows me that workspace is not under git source control.

What I've tried:

I've tried setting the git.path in the user settings.json file, with "git.path": "/usr/local/bin/git", saving those settings, then restarting VS Code. Still nothing better, and according to others who have used it, they don't even have to set their git.path. I'm at the point where I'm considering getting rid of VS Code all together, delete all installed packages, and restarting from scratch, however I'm starting to feel this is some type of weird bug.

-Stu

Activity

  1. joaomoreno commented on Feb 12, 2016

    @joaomoreno
    Contributor

    Which OS?

    If Code reports This workspace isn't yet under git source control., then it can easily find git itself. No need to set the git.path setting.

    Are you sure you opened VS Code on the folder that is the root of the git repository?

    For example, I have a Work folder in which I have many git repositories, e.g. Work/vscode is one of them. Opening the Work folder with VS Code will not work. But opening Work/vscode should work.

  2. stuartweir commented on Feb 12, 2016

    @stuartweir
    Author

    Ahhhh sorry, I left out the OS! I even tried to be as clear as possible haha. I'm on Mac! As for the last part you described, yes it's in goadesign/goa, for example, where goa is the git repo.

  3. joaomoreno commented on Feb 12, 2016

    @joaomoreno
    Contributor

    And you do open the goa folder in VSCode, as in File > Open and select the goa folder?

  4. stuartweir commented on Feb 12, 2016

    @stuartweir
    Author

    Yep

  5. joaomoreno commented on Feb 12, 2016

    @joaomoreno
    Contributor

    Which git version do you have? What exact output do you get when running git status in the goa folder?

  6. stuartweir commented on Feb 12, 2016

    @stuartweir
    Author

    git version 2.5.4 (Apple Git-61)
    hub version 2.2.2

    ~/g/s/g/g/goa ❯❯❯ git status
    On branch master
    Your branch is up-to-date with 'origin/master'.
    nothing to commit, working directory clean

  7. joaomoreno commented on Feb 17, 2016

    @joaomoreno
    Contributor

    Sorry, just one more command. What do you get with git status -z -u?

  8. stuartweir commented on Feb 18, 2016

    @stuartweir
    Author

    I get no printout at all

  9. joaomoreno commented on Feb 18, 2016

    @joaomoreno
    Contributor

    This is strange. Your setup looks OK to me. Just as to why Code thinks your folder is not a git repository is beyond my knowledge.

    Let's try something else. Can you try creating a brand new repo and opening that in Code?

    cd ~/Desktop
    mkdir repo
    cd repo
    git init
    code .
    

    And check whether Code thinks the repo folder is a git repo or not.

  10. stuartweir commented on Feb 18, 2016

    @stuartweir
    Author

    Yeah this is strange, and only getting more strange. It sees it as a git repo.

  11. joaomoreno commented on Feb 18, 2016

    @joaomoreno
    Contributor

    Cool. Does the path to goa perhaps involve symlinks at all?

  12. stuartweir commented on Feb 18, 2016

    @stuartweir
    Author

    No, at least not on my computer. In Go, it's fairly commonplace to pull a repo from the actual public project directory (in this case https://github.com/goadesign/goa ) and then fork the repo on github, and set my local goa project directory (mine is $GOPATH/src/github.com/goadesign/goa) to point to my remote fork on github, so when I push it goes to github.com/stuartweir/goa. The reason for this is to maintain the import paths for package dependencies in goa for my local version. I hope this makes sense, but I'm starting to wonder if that's possibly the problem?

  13. joaomoreno commented on Feb 18, 2016

    @joaomoreno
    Contributor

    That is OK. Can you try cloning the goa repo (either the original, or your fork) into ~/Desktop/goa?

  14. justinboyd commented on May 25, 2016

    @justinboyd

    I'm also running into this issue where I'm developing on a repo clone, but VS Code isn't picking it up as a repository.

    I'm on a Windows 7, 64-bit machine.
    Git version 2.8.3

  15. joaomoreno commented on May 25, 2016

    @joaomoreno
    Contributor

    justinboyd can you show me a screenshot?

  16. justinboyd commented on May 25, 2016

    @justinboyd

    I can provide a screenshot later tonight or tomorrow, but I'm beginning to believe this is an issue with Git and not VS Code.

    When executing the "git status" command on my clone repo I get the following error:

    "error: object directory /[Path]/.git/objects does not exist; check .git/objects/info/alternates.
    error: refs/heads/master does not point to a valid object!
    error: refs/remotes/origin/HEAD does not point to a valid object!
    error: refs/remotes/origin/master does not point to a valid object!
    No revs to be shown."

    This does not happen when i execute "git status" on the master repo. I'm a little new to GIT and am more familiar with TFS. This may be a rookie mistake on my part.

  17. joaomoreno commented on May 26, 2016

    @joaomoreno
    Contributor

    Definitely sounds like an issue with your repo indeed. Will close this since Stu Weir (@stuartweir) didn't report more info.

  18. justinboyd commented on May 27, 2016

    @justinboyd

    I just wanted to post a follow up in case anyone else runs into this issue. I'm not sure if Stu Weir (@stuartweir) had a similar setup, but this was the result of my issue.

    I have an unconventional setup where I have my project hosted on dropbox and I use Git to version the project. At home I work on the project on a mac, at work I'm on windows. The problem was that I cloned my main repo on my mac to a different directory on dropbox, then when I tried to use Git on windows it cause a lot of errors. When I booted my project on my mac I was able to version fine and ran into no errors.

    A rookie mistake, but I learned my lesson.

  19. castanjt commented on Jan 16, 2017

    @castanjt

    I wanted to follow up as well since I encountered the same problem. I'm using Visual Studio Code for WordPress development. I have a theme under version control, but not the entire site. When opening VS Code at the root, then navigating down to the theme directory, it didn't recognize my repo. When opening the theme directory by itself in a separate workspace, it did recognize the repo.

    TL;DR - If you run into this problem where you've initialized a Git repo outside VS Code and VS Code isn't recognizing it, try opening the folder where you created the repo directly in VS Code rather than a parent directory.

    Hope this helps!

  20. locked and limited conversation to collaborators on Nov 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

info-neededIssue requires more information from poster

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions