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.
- Confirm the difference: run
git --versionin a new standalone terminal and in VS Code’s terminal. - Quit VS Code completely — all windows — and start it again. On macOS, Quit from the menu; closing the window is not enough.
- 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:
where.exe git # Windows
which git # macOS/Linux
{
"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 initin the terminal. - The repository is nested deeper than VS Code scans. Set
git.autoRepositoryDetectiontotrueorsubFolders, 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 manageron Windows,osxkeychainon macOS,libsecretorstoreon 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.terminalAuthenticationto 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:
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 explained — what Source Control is doing.
- Git branching for beginners — once it works.
- VS Code setup for beginners — the rest of the editor.