Troubleshoot source control
Use this article to resolve common Git problems in Visual Studio Code. Start with the symptom that matches your problem, then use the Git Output window to collect more information if the suggested fix doesn't resolve it.
Push, pull, or sync doesn't finish
A Git operation that doesn't finish often indicates that Git is waiting for authentication but the credential prompt isn't visible.
-
Open the Git Output window and check the most recent command for an authentication error.
-
Configure a Git credential helper for your operating system.
-
Run the operation again and complete any sign-in prompt.
Git Credential Manager is the recommended credential helper for Windows, macOS, and Linux. Git for Windows includes Git Credential Manager.
Git authentication prompts appear repeatedly
VS Code automatically fetches remote changes to show incoming commits. The authentication prompt comes from your Git credential helper, not from VS Code.
Configure a Git credential helper to store your credentials. If you don't want VS Code to fetch in the background, turn off the git.autofetch setting.
Git actions are unavailable after initializing a repository
Push, pull, and sync require a remote repository. If you initialized a local repository, add a remote or use Publish to GitHub in the Source Control view.
After the branch has an upstream remote, VS Code makes the synchronization actions available.
VS Code reports that a repository is potentially unsafe
Git blocks operations in a repository owned by a different operating-system user. This protects you from running Git configuration or hooks from an untrusted repository.
Select Manage Unsafe Repositories in the Source Control view or notification. Review the repository location before you mark it as safe. Marking a repository as safe adds its location to Git's safe.directory configuration.
On Windows, this can happen when you clone a repository from an application running as administrator and later open it from an application that isn't running as administrator.
VS Code doesn't detect a repository in a parent folder
VS Code doesn't automatically open Git repositories in parent folders because doing so can expose changes outside the folder you intended to work with.
When VS Code detects a repository in a parent folder, use the notification or Source Control welcome view to open it. To always open repositories in parent folders, set the
git.openRepositoryInParentFolders
setting to always.
Open the Git Output window
VS Code uses your machine's Git installation for source control operations. The Git Output window records the Git executable, commands, errors, timestamps, and command duration.
Open the Git Output window in one of these ways:
- In the Source Control view, select More Actions (...) > Show Git Output.
- Run Git: Show Git Output from the Command Palette (⇧⌘P (Windows, Linux Ctrl+Shift+P)).
- Open the Output panel (⇧⌘U (Windows Ctrl+Shift+U, Linux Ctrl+K Ctrl+H)) and select Git from the channel list.

Review the most recent command and error message. The first error after the command is usually more useful than later errors that result from it.
By default, the Git Output window shows standard output only when a command fails. Use the git.commandsToLog setting to choose commands that should always log their standard output.
Filter and search Git logs
Use the Output panel filters to reduce the amount of log information:
- Select a log level such as
trace,debug,info,warning, orerror. The default level isinfo. - Select a category such as
gitorrepository. Selectgitto focus on commands executed by Git.

Use the search box (⌘F (Windows, Linux Ctrl+F)) to find a command, repository path, or error. The search box supports regular expressions.

Collect trace logs
Enable trace logging when the regular Git output doesn't contain enough information:
-
Open the Git Output window.
-
Select the gear icon in the Output panel header.
-
Select Trace.

-
Reproduce the problem and review the new log entries.
Trace logs can contain repository paths, remote URLs, branch names, and other development information. Review the output and remove sensitive information before you share it.
Next steps
- Repositories and Remotes - Configure remotes and synchronization
- Source Control FAQ - Review product support and compatibility questions
- Git documentation - Learn more about Git commands and configuration