Jan
Jan

Reputation: 161

How to configure VS Code on MacOS for git.path?

I installed VS Code on my Mac, and I try to connect it to git. However VS Code indicates that it can’t find git.

I have tried modify the variabele git.path to “/usr/bin” (where I can see that git is installed). However when starting VS Code it still indicates that git is not there.

Upvotes: 15

Views: 19422

Answers (2)

Ogre Psalm33
Ogre Psalm33

Reputation: 21946

I found a specific issue on the vscode github page related to this. The issue submitter's solution to this worked for me, which is to open a terminal and type the following command

sudo xcodebuild -license

This will prompt you to read and then accept the license agreement. Once I did this, I restarted Visual Studio Code and my issue was solved.

Apparently there is some subtle issue that keeps VS Code from recognizing git (or that git is "valid"?) until the xcodebuild license has been accepted.

Upvotes: 8

cody.codes
cody.codes

Reputation: 1537

I had this issue and was able to solve it by installing Xcode Command Line Tools and updating VSCode's settings.json

You can open this file a couple different ways. I like to do + Shift + P then type "settings" in the command palette: settings

If you prefer just to open it, its location is here:

$HOME/Library/Application Support/Code/User/settings.json

Reference: Visual Studio Code User and Workspace Settings

Then plug the following into your workspace settings (ensure that you merge your current config you may have here):

{
    "git.path": "/usr/bin/git"
}

And it'll look something like this:

workspace settings

Now close VSCode. If you'd like to use the Terminal you can simply input this command, but you can use the GUI instead if you'd like as I'll show:

xcode-select --install

Wait for the command to complete, then start VSCode. At this point my issue was fixed; hopefully this works for you as well!

Since I'd already installed my XCode tools my dialog won't show up again, but you can see from this image which is referenced below what it looks like. Click "Install".

from http://railsapps.github.io/xcode-command-line-tools.html

Both command and image referenced from here: http://railsapps.github.io/xcode-command-line-tools.html

Upvotes: 23

Related Questions