Install, find Git, settings that matter
Beginner VS Code UI
Why this matters
Two of the most common "VS Code is broken" reports are really configuration: Git is not installed or not found, and smart commit is on. Both take a minute to settle, and settling them now saves confusing behaviour later.
Install
VS Code comes from code.visualstudio.com. Git is separate: VS Code does not bundle it and cannot do anything with source control until Git is installed (lesson 3.1).
To confirm both:
$ git --versiongit version 2.51.0If that works in your terminal but VS Code still says Git is not found, restart VS Code: it reads the PATH at launch, and an editor started before Git was installed will not see it.
The six settings
Command Palette → Preferences: Open Settings (UI), then search for each. The identifiers below are what you would put in settings.json, and what a colleague will name when helping you.
| Setting | Set it to | Why |
|---|---|---|
git.autofetch |
true |
Keeps the incoming and outgoing counts on the Sync button honest, without changing your files |
git.enableSmartCommit |
false |
With it on, Commit with nothing staged commits everything, which is the single biggest surprise in VS Code's Git support |
git.confirmSync |
true |
Sync is pull-then-push; a confirmation is worth it while you are learning |
git.postCommitCommand |
none |
Leave commit and push as separate decisions |
git.path |
The full path to git |
Only if VS Code cannot find Git |
git.defaultBranchName |
main |
New repositories start on main (lesson 3.3) |
Smart commit deserves the emphasis. It is convenient once you are used to it and a trap before then: staging is how you choose what goes into a commit (lesson 5.3), and a setting that quietly commits everything removes that choice.
Settings as JSON
Command Palette → Preferences: Open User Settings (JSON) shows the file behind the interface:
{
"git.autofetch": true,
"git.enableSmartCommit": false,
"git.confirmSync": true,
"git.postCommitCommand": "none",
"git.defaultBranchName": "main",
"editor.renderWhitespace": "boundary",
"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true
}The last three are not Git settings but prevent Git noise: trailing whitespace and missing final newlines produce diffs that are entirely about invisible characters.
Settings exist at two levels: User, which applies everywhere, and Workspace, stored in .vscode/settings.json inside the project. Workspace settings are committed and shared, which is how a team agrees on indentation without discussing it again.
When VS Code cannot find Git
The error is "Git not found. Install it or configure it using the 'git.path' setting."
- Confirm Git exists:
git --versionin a terminal outside VS Code. - If it does, restart VS Code so it re-reads
PATH. - If it still fails, find the full path:
which giton macOS or Linux,where giton Windows. - Set
git.pathto that path in User settings. - Restart VS Code once more.
On Windows the path is usually C:\\Program Files\\Git\\bin\\git.exe; note that JSON needs the backslashes doubled.
How to do it
The two commands that settle whether the problem is Git or VS Code:
$ git --version
$ which gitIf both work in a terminal and VS Code disagrees, the problem is PATH or git.path, not Git.
Command Palette (⇧⌘P on macOS, Ctrl+Shift+P elsewhere) is the way into everything in this section:
- Preferences: Open Settings (UI)
- Preferences: Open User Settings (JSON)
- Shell Command: Install 'code' command in PATH
- Developer: Reload Window, which is faster than restarting
IntelliJ finds Git at Settings → Version Control → Git → Path to Git executable, with a Test button that reports the version. See lesson 16.1.
Nothing platform-specific here; this is between your editor and your computer.
The same.
Common mistakes
- Expecting VS Code to include Git. It does not.
- Leaving smart commit on, then wondering why unrelated files are in the commit.
- Setting
git.pathfirst, before checking whether a restart fixes it. - Editing Workspace settings when you meant User settings, which commits your personal preferences to the team's repository.
- Forgetting to double backslashes in a Windows path in JSON.
Try it yourself
Goal: set the six settings and confirm the editor and Git agree.
- Run
git --versionin VS Code's integrated terminal. - Open Preferences: Open User Settings (JSON) and set the six settings from the table.
- Confirm
git.enableSmartCommitisfalseby staging nothing and checking the Commit button's behaviour: it should refuse rather than commit everything. - Install the
codecommand, then close VS Code, runcode .in your project folder, and see it reopen. - Add a
.vscode/settings.jsonto your practice project withfiles.insertFinalNewlineand commit it.
Expected result: an editor that finds Git, does not commit things you did not stage, and shares its formatting settings with anyone who clones the project.
Show solution
Step 3 is the one worth doing rather than assuming. With smart commit off, committing with an empty staging area gives you a message rather than a surprise commit, and that message is what teaches the habit of staging deliberately.