Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

macos

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.

like image 727
Jan Avatar asked Jul 18 '18 08:07

Jan


People also ask

How do I set path VS Code on Mac?

Drag Visual Studio Code.app to the Applications folder, making it available in the macOS Launchpad. Open VS Code from the Applications folder, by double clicking the icon. Add VS Code to your Dock by right-clicking on the icon, located in the Dock, to bring up the context menu and choosing Options, Keep in Dock.

Where is git path in VS Code?

Open setting. json(or File>Preferences>Settings). Navigate to Workspace Settings. Find "Path" and add paths to Git bin and cmd folders.


2 Answers

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.

like image 35
Ogre Psalm33 Avatar answered Sep 19 '22 20:09

Ogre Psalm33


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

like image 199
cody.codes Avatar answered Sep 21 '22 20:09

cody.codes