Skip to content
Happy Programming Guide
Start learning
Coding Tools

Git Not Working in the VS Code Terminal

git works in a normal terminal but not inside VS Code, or the Source Control view says no repository. PATH inheritance, the git.path setting, the wrong folder, and credential prompts.

A small beetle photographed up close

Git in VS Code fails in two separate places, and it helps to know which one you are looking at. The integrated terminal is a real shell that must find git on its PATH, just like any terminal. The Source Control view is VS Code’s own Git integration, which finds the executable separately and needs a repository in the open folder. The four causes below cover almost every “git not working” report on either side.

Cause 1: VS Code has an old PATH#

The integrated terminal inherits its environment from VS Code, and VS Code inherits its environment from however it was launched. If Git was installed while VS Code was open, or VS Code was started from a shortcut that does not read your shell profile, the terminal inside it has a PATH without Git even though a fresh standalone terminal does.

  1. Confirm the difference: run git --version in a new standalone terminal and in VS Code’s terminal.
  2. Quit VS Code completely — all windows — and start it again. On macOS, Quit from the menu; closing the window is not enough.
  3. Better: start it from a terminal where git works, with code ., so it inherits that environment.

This resolves the majority of cases. On macOS in particular, an app launched from the Dock may not have read ~/.zshrc; launching from the terminal sidesteps that.

Cause 2: tell VS Code where git is#

The Source Control view uses its own lookup. If it reports that Git is not found, or is using an old version, set the path explicitly:

Terminal
where.exe git           # Windows
which git               # macOS/Linux
JSON
{
  "git.path": "C:\\Program Files\\Git\\cmd\\git.exe"
}

Use the cmd\git.exe path on Windows, not the one under bin. Reload the window afterwards. The Output panel’s Git channel logs which executable it found and every command it runs, which is the place to look when the view behaves oddly.

Cause 3: Source Control shows nothing#

“No source control providers registered” or an empty view with an Initialize Repository button means VS Code found Git but not a repository. Either:

  • The open folder is not the repository root and not inside one. Open the folder that contains .git, or a subfolder of it.
  • There is no repository yet. Click Initialize Repository, or run git init in the terminal.
  • The repository is nested deeper than VS Code scans. Set git.autoRepositoryDetection to true or subFolders, or open the subfolder directly.
  • The Git extension is disabled. Check the Extensions view for the built-in Git extension and enable it.

Cause 4: credentials#

Push and pull that fail with an authentication error, or hang waiting for a password prompt you cannot see, are credential problems rather than Git problems.

  • Enable the built-in GitHub authentication: the Accounts icon in the activity bar, sign in to GitHub. VS Code then handles HTTPS credentials for GitHub itself.
  • For other hosts, make sure a credential helper is configured so Git remembers the token: git config --global credential.helper manager on Windows, osxkeychain on macOS, libsecret or store on Linux.
  • For SSH remotes, the terminal needs an agent with your key loaded. If a standalone terminal can push and VS Code cannot, the agent environment variables were not inherited; launch from that terminal.
  • Set git.terminalAuthentication to true (the default) so the integrated terminal uses VS Code’s stored credentials.

A prompt that appears on every push means no helper is storing the credential; a push that hangs forever means a prompt is waiting on a hidden channel — run the same command in the terminal to see it.

Git Bash, PowerShell and WSL#

The integrated terminal can run different shells, and each has its own PATH. Git installed for Windows is visible to PowerShell and cmd; inside a WSL terminal, it is the Linux git that matters, installed with apt. Check which shell the terminal is running from its dropdown, and install or configure git for that shell.

In a Remote or WSL window, the Source Control view uses the git on the remote side, not your local one. Install it there.

Line endings and file status noise#

Every file showing as modified with no visible change is line endings, usually after cloning on Windows with core.autocrlf unset. Not a broken Git, but it looks like one:

Terminal
git config --global core.autocrlf true      # Windows
git config --global core.autocrlf input     # macOS/Linux

Questions people ask#

Do I need GitLens?

No. The built-in Git support handles staging, committing, branching, diffs and blame. GitLens adds history views and annotations on top.

Why does the terminal use a different git than Source Control?

The terminal uses the shell’s PATH; Source Control uses git.path or its own search. Set git.path to the same executable to keep them consistent.

Source Control works but commit does nothing.

Usually a missing user.name or user.email. Set both with git config --global; the Git output channel shows the error.

Can I use VS Code as the Git editor for commit messages?

Yes: git config --global core.editor "code --wait". Then git commit from any terminal opens a tab.

Where to go next#

Git and GitHub explainedRead next

Keep reading

Keep going — pick your next guide

The fastest way to improve is to read one guide, then build the thing it describes. Start with the basics, or jump straight to a project.

Ask a question or share what worked

Your email address will not be published. Required fields are marked *