You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
VS Code not recognizing a git repo workspace #2947
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:
Open VS Code
Open workspace already initialized with git.
Click the Git icon on the side.
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.
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.
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.
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?
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.
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.
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.
Activity
joaomoreno commentedon Feb 12, 2016
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 thegit.pathsetting.Are you sure you opened VS Code on the folder that is the root of the git repository?
For example, I have a
Workfolder in which I have many git repositories, e.g.Work/vscodeis one of them. Opening theWorkfolder with VS Code will not work. But openingWork/vscodeshould work.stuartweir commentedon Feb 12, 2016
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, wheregoais the git repo.joaomoreno commentedon Feb 12, 2016
And you do open the
goafolder in VSCode, as inFile > Openand select thegoafolder?stuartweir commentedon Feb 12, 2016
Yep
joaomoreno commentedon Feb 12, 2016
Which git version do you have? What exact output do you get when running
git statusin thegoafolder?stuartweir commentedon Feb 12, 2016
git version 2.5.4 (Apple Git-61)hub version 2.2.2~/g/s/g/g/goa ❯❯❯ git statusOn branch masterYour branch is up-to-date with 'origin/master'.nothing to commit, working directory cleanjoaomoreno commentedon Feb 17, 2016
Sorry, just one more command. What do you get with
git status -z -u?stuartweir commentedon Feb 18, 2016
I get no printout at all
joaomoreno commentedon Feb 18, 2016
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?
And check whether Code thinks the
repofolder is a git repo or not.stuartweir commentedon Feb 18, 2016
Yeah this is strange, and only getting more strange. It sees it as a git repo.
joaomoreno commentedon Feb 18, 2016
Cool. Does the path to
goaperhaps involve symlinks at all?stuartweir commentedon Feb 18, 2016
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 togithub.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?joaomoreno commentedon Feb 18, 2016
That is OK. Can you try cloning the goa repo (either the original, or your fork) into
~/Desktop/goa?justinboyd commentedon May 25, 2016
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
joaomoreno commentedon May 25, 2016
justinboyd can you show me a screenshot?
justinboyd commentedon May 25, 2016
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.
joaomoreno commentedon May 26, 2016
Definitely sounds like an issue with your repo indeed. Will close this since Stu Weir (@stuartweir) didn't report more info.
justinboyd commentedon May 27, 2016
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.
castanjt commentedon Jan 16, 2017
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!