Git Course 0%

Install, find Git, settings that matter

Beginner VS Code UI ≈ 8 min

What you will learn

  • How VS Code finds Git, and how to point it somewhere else
  • The settings that prevent the common surprises
  • How to open settings as JSON and share them with a team

After this lesson you can

  • My editor and my Git agree, and the defaults that cause confusion are turned off

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:

Terminal
$ git --version
git version 2.51.0

If 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:

settings.json
{
  "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."

  1. Confirm Git exists: git --version in a terminal outside VS Code.
  2. If it does, restart VS Code so it re-reads PATH.
  3. If it still fails, find the full path: which git on macOS or Linux, where git on Windows.
  4. Set git.path to that path in User settings.
  5. 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:

Terminal
$ git --version
$ which git

If both work in a terminal and VS Code disagrees, the problem is PATH or git.path, not Git.

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.path first, 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.

  1. Run git --version in VS Code's integrated terminal.
  2. Open Preferences: Open User Settings (JSON) and set the six settings from the table.
  3. Confirm git.enableSmartCommit is false by staging nothing and checking the Commit button's behaviour: it should refuse rather than commit everything.
  4. Install the code command, then close VS Code, run code . in your project folder, and see it reopen.
  5. Add a .vscode/settings.json to your practice project with files.insertFinalNewline and 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.

Check yourself

1. VS Code says Git is not found, but git --version works in your terminal. What is the first thing to try?
2. What does git.enableSmartCommit do when it is on?
3. Where do settings live that should be shared with the whole team?

Key terms

Editor IDE Configuration