VS Code doesn’t ship its own copy of Git. It calls whatever Git is installed on your computer for every clone, fetch, pull, and push, so install that first. After that, the usual route is a single command, Git: Clone, plus a browser sign-in if the repository is private.
You don’t need an extension for any of this. As of the October 2026 VS Code documentation, Git authentication is built in and needs no extension. People often install GitHub Pull Requests and Issues thinking it’s required, but all it adds is a Pull Requests view and an Issues view.
Plenty of people are doing this. Stack Overflow’s 2025 Developer Survey ranked Visual Studio Code first among developer environments, with 75.9% of respondents using it.
Which Method Should You Use to Connect VS Code to a GitHub Repository?
It depends on what already exists. If the repository is on GitHub and you want it on your machine, clone it. A local folder that has never been on GitHub gets Publish to GitHub. When both the folder and the GitHub repository already exist, you use Add Remote, and for a quick edit without downloading anything there’s the GitHub Repositories extension.
Under the hood, “connected” just means VS Code’s built-in Git support is pointed at a GitHub remote. That support handles clone, fetch, pull, and push, and it requires Git installed on your machine (VS Code documentation, October 2026).
VS Code runs Git for those operations. Git is the thing actually talking to GitHub. If those two still blur together for you, this explainer on the difference between Git and GitHub is worth five minutes.
| Your situation | Method | Where files live | What it needs |
|---|---|---|---|
| Repository on GitHub, no local copy | Clone | Your machine | Git, sign-in for private repos |
| Local folder, no GitHub repository | Publish to GitHub | Your machine | Git, GitHub sign-in |
| Local folder and GitHub repository both exist | Add Remote | Your machine | Remote URL, credentials at first push |
| Quick edit, no local copy | GitHub Repositories extension | Remote virtual workspace | Extension, sign-in |
Most of the time you’ll clone. The remote-only option has no terminal, tasks, or debugging, which is fine for fixing a typo and pretty limiting for anything else.
What Do You Need Before Connecting VS Code to GitHub?
Git comes first, since VS Code uses your installation for everything. You’ll also want a GitHub account (required for private repositories and for any push) and a name and email set in Git so your commits are labeled.
Check the install by running git --version in the integrated terminal. If the command fails, install Git and restart VS Code.
Not sure how to install it on your system? The Git installation walkthrough covers each operating system. GitHub’s own setup page points to git-scm.com for the download.
Every so often Git works fine in the terminal and VS Code still says it can’t find it. I’ve hit this on machines with more than one Git install. Set git.path to the full path of the Git executable and restart VS Code.
Your commit identity goes into the global Git configuration with the git config command:
git config --global user.name "Your Name"
git config --global user.email "you@example.com"These only put a name on your commits. They aren’t sign-in credentials, and authentication is its own step further down.
On Windows you’re slightly ahead. Git for Windows includes Git Credential Manager, which VS Code’s documentation calls the recommended credential helper, and the same installer ships Git Bash.
How to Clone a GitHub Repository in VS Code

On a normal connection the whole thing takes under a minute. You run Git: Clone from the Command Palette, give it a URL (or pick a repository through Clone from GitHub), choose where it goes, and open it.
The clone gets a remote named origin automatically. GitHub describes the result as a full copy of the repository data, including every version of every file.
A clone doesn’t give you permission to push, though. If the repository isn’t yours and you can’t write to it, fork it on GitHub and clone your fork instead.
Clone From the Command Palette or Source Control View
- Press Ctrl+Shift+P (Cmd+Shift+P on macOS) and run Git: Clone. With no folder open, you can select Clone Repository in the Source Control view instead.
- Paste the repository URL, or choose Clone from GitHub and pick a repository from the list. Sign in through the browser when prompted.
- Choose a local folder for the clone.
- Select the option to open the cloned repository, in this window or a new one.
For a public repository cloned by URL you usually won’t be asked to sign in at all. The browser prompt shows up for private repositories and the first time you push.
That’s partly why a bare URL so often just works. Public and open source repositories made up 63% of all repositories on GitHub in 2025 (Octoverse 2025).
Clone From the Integrated Terminal
I tend to use the terminal when I care about the folder name or exactly where the clone lands. Open it with Ctrl+`, move into the parent folder, and run:
git clone https://github.com/user/repo.gitThis is the same git clone command the Command Palette runs for you. Open the new folder with File, then Open Folder, and it appears in the Source Control view.
Every repository has an HTTPS URL, https://github.com/user/repo.git, and an SSH one, git@github.com:user/repo.git. Which you should use comes down to how you authenticate, and that’s covered below.
How to Connect a Local Folder to a GitHub Repository

People mix these two up constantly. Publish to GitHub is for when the GitHub repository doesn’t exist yet. Add Remote is for when it does.
Publish to GitHub for a New Repository
If the folder isn’t a Git repository yet, initialize it first with the Initialize Repository button in the Source Control view.
Then run Publish to GitHub from the Command Palette and sign in if asked. Enter a repository name, choose public or private, and select the files for the initial commit if prompted.
VS Code creates the repository on GitHub, adds it as a remote, and pushes your commits, all in one go. Don’t use this if the repository already exists on GitHub. Add it as a remote instead.
Add a Remote for an Existing Repository
Open the Source Control view, then More Actions (…) > Remotes > Add Remote, or run Git: Add Remote from the Command Palette. Paste the GitHub URL, then type a name.
Most people name it origin. If you add a second one later, like the project you forked from, that’s usually called upstream.
Adding a remote uploads nothing and sets no upstream. The link between your branch and its upstream branch happens on your first push.
There’s a third button that adds to the confusion. Publish Branch shows up in the status bar whenever your current branch has no upstream, and it uploads that branch to a remote that already exists and sets the upstream. Compare that with Publish to GitHub, which creates a brand new hosted repository, wires up the remote and pushes. Add Remote is the quiet one. It links the folder to a URL and stops there.
So pick based on what already exists, not on which button happens to look closest.
How to Open a GitHub Repository in VS Code Without Cloning
With the GitHub Repositories extension installed, run GitHub Repositories: Open Repository from the Command Palette, or choose Open GitHub Repository from the remote indicator in the lower left corner.
Edits made this way commit directly to the remote branch. There’s no local copy, so there’s nothing to push later (which is convenient right up until you commit something you meant to test).
When the virtual workspace isn’t enough, the Continue Working On command lets you move the work elsewhere. You can carry on in a local clone on your machine. Or open a Codespace, which is a dedicated VM configured from a devcontainer.json file, with a terminal; it can take a few minutes to start and requires the GitHub Codespaces extension. Cloning into a Docker container is also an option, if you have Docker and the Container Tools extension.
Separately, there’s github.dev, which runs entirely in the browser. Press the period key on a repository page, or change github.com to github.dev in the URL.
If you want the cloud setup but with a real terminal, that’s Codespaces, and this overview of how GitHub Codespaces works covers the setup side.
github.dev has a couple of rough spots. Unsaved work lives in browser local storage until you commit it, and heavy editing can hit API rate limits that cause push failures.
My own habit: README fixes and config tweaks go through the extension. Anything that needs a build gets cloned.
How Does VS Code Authenticate With GitHub?
Most people sign in through the browser and never think about it again. The other options are a personal access token stored by a credential helper, and an SSH key.
| Method | Credential | Works well for | Breaks when |
|---|---|---|---|
| Browser sign-in | GitHub account, authorized in the browser | One personal machine, HTTPS URLs | The redirect back to VS Code fails |
| Token plus Git Credential Manager | Personal access token stored by the helper | Terminal clones over HTTPS | The token expires or the organization blocks it |
| SSH key | Key pair, public half on your account | Many repositories, one key | The key is not loaded in ssh-agent |
On a single machine, browser sign-in is usually all you need. SSH starts to make more sense once you’re working across lots of repositories and would rather have one key behind all of them.
Browser Sign-In (Default)
You authorize VS Code in the browser and get sent back to the editor. There’s no token to create and no key to generate.
If the redirect back fails, you can paste a token manually from the status bar. GitHub Enterprise Server users on self-hosted setups go a different way, described in the token section below.
HTTPS With a Personal Access Token and Git Credential Manager
This part is confusing because the two sets of docs seem to disagree. According to the VS Code documentation (October 2026), personal access tokens are supported only for GitHub Enterprise Server in the built-in flow, where you cancel the browser prompts until VS Code asks for a token. GitHub’s documentation, on the other hand, says HTTPS credentials are a username plus a personal access token, or a credential helper such as Git Credential Manager.
They’re answering different questions. VS Code is talking about what its own sign-in prompt accepts. GitHub is talking about what Git over HTTPS accepts.
Passwords are out either way. GitHub scheduled the end of password authentication for Git operations for August 13, 2021, and its current documentation says it has been removed. A password typed at a Git prompt fails, while a personal access token is what GitHub requires instead.
GitHub recommends fine-grained tokens, which are scoped to one owner and only reach the repositories you choose. Classic tokens are broader and can get at every repository you have access to. There’s one case where you still need a classic token, though: writing to public repositories you neither own nor belong to.
Either type takes about a minute to generate, and the guide to getting a GitHub token shows where the settings live.
Git Credential Manager supports GitHub and GitHub Enterprise Server on Windows 10 and later, macOS 14 and later, and Linux distributions that .NET supports. When you push, it opens a window and walks you through sign-in.
SSH Key Setup
VS Code uses the SSH configuration from your Git installation. So if the key doesn’t work in a plain terminal, it won’t work in the editor either. Get it working there first.
- Generate the key. Run
ssh-keygen -t ed25519 -C "your_email@example.com". If the system does not support Ed25519, usessh-keygen -t rsa -b 4096with the same email flag. Enter a passphrase when prompted. - Load it into ssh-agent. Start the agent with
eval "$(ssh-agent -s)", then runssh-add ~/.ssh/id_ed25519on Linux. On Windows, start the ssh-agent service from an elevated PowerShell window, then run ssh-add from a non-elevated one. - Add the public key to GitHub. Open Settings, then SSH and GPG keys, then New SSH key. Pick the Authentication type and paste the public key.
- Test it. Run
ssh -T git@github.comand look for a message saying you have successfully authenticated but GitHub does not provide shell access. On the first connection, compare the fingerprint with GitHub’s published ones before typing yes.
The walkthrough for adding an SSH key to GitHub shows the account screens in more detail.
The Signing key type is for commits and tags, not for connecting. If you want one key doing both jobs, you have to upload it twice, once as each type. And GitHub dropped DSA keys on March 15, 2022, so stick to Ed25519 or RSA.
Do You Need the GitHub Pull Requests Extension?
No. Git authentication is built into VS Code and needs no extension.
What the GitHub Pull Requests and Issues extension gives you is a Pull Requests view and an Issues view, with sign-in from the GitHub icon in the Activity Bar. It’s nice if you review pull requests inside the editor. It has nothing to do with connecting.
How to Confirm the Connection and Sync Changes
Run git remote -v in the repository folder. If things are set up right, you’ll see origin listed twice, once marked fetch and once marked push, both with your GitHub URL.
VS Code’s own troubleshooting guide uses that same command to check that the fetch and push URLs point at the repository you meant. If a URL turns out to be wrong, the git remote command can edit it.
Inside the editor, the status bar shows the active branch and the sync actions. Open the Source Control view with Ctrl+Shift+G to see changed files and stage them.
| Action | What it does | What it leaves alone |
|---|---|---|
| Fetch | Downloads remote commits | Your branch and files |
| Pull | Integrates remote commits (commit or stash first) | Does not push |
| Push | Uploads local commits | Skips uncommitted changes, does not pull |
| Sync Changes | Pulls, then pushes | Stops before pushing when conflicts occur |
The table follows VS Code’s repositories and remotes documentation (October 2026). The arrows in the status bar count outgoing and incoming commits against the upstream, but those counts are based on the last known remote state, which can be stale.
A fetch is what refreshes them (here is what git fetch does under the hood).
Auto-fetch is a separate setting. The git.autofetch setting is off by default in the editor window, git.autofetchPeriod defaults to 180 seconds, and auto-fetch never pulls or pushes.
Why Does the Connection Fail, and How Do You Fix It?
Most failures I’ve seen come down to stale credentials, a bad URL, or an SSH key that isn’t loaded. Pushes you don’t have rights to, and pushes rejected because the remote moved ahead, make up most of the rest.
| Error | Cause | Fix |
|---|---|---|
| Authentication failed | Wrong account or stale credentials in the credential helper | Update the stored credentials and retry |
| Repository not found | Typo in the URL, or no access to a private repository | Copy the URL from the repository page and check access |
| Permission denied (publickey) | Key not loaded in ssh-agent, or public key missing from the account | Run ssh-add, add the key, test with ssh -T |
| Cannot push after a successful sign-in | Read-only access, or credentials for another account | Request write access or update stored credentials |
| Push rejected (non-fast-forward) | Remote has commits your branch lacks | Fetch, pull, resolve conflicts, push again |
Sources: VS Code’s troubleshooting guide for the authentication and push rows, GitHub’s cloning errors page for the URL row, and GitHub’s publickey page for the key row.
Don’t force push your way past a rejection. A force push can overwrite commits other people depend on. Resolve any merge conflicts from the pull, then push normally.
Some problems look like authentication failures and aren’t.
- A protected branch won’t accept your push no matter how cleanly you signed in. Push to a branch you’re allowed to use and open a pull request.
- If a push, pull or sync just hangs, it may be waiting on a sign-in prompt that’s hidden behind another window.
- Getting asked to sign in over and over? Background fetches from git.autofetch can trigger the prompts.
- Organizations using SAML SSO need you to authorize a classic token for the organization before authenticating.
- An organization can block classic tokens entirely, and requests then return a 403 response.
- SSH connections must use the git user, not your GitHub username.
- GitHub automatically removes tokens unused for a year.
Windows has one extra quirk. A repository cloned from an elevated application can be blocked when you open it from a non-elevated one. Manage Unsafe Repositories clears it once you’ve checked the location.
Whatever the error, look at the Git Output window first. It shows the exact command that failed and the full error message. If you need more, git.commandsToLog logs standard output for specific commands.
FAQ About Connecting to a GitHub Repository From VS Code
How do you switch a remote from HTTPS to SSH in VS Code?
In the integrated terminal, run git remote set-url origin git@github.com:user/repo.git, then check it with git remote -v. This swaps the URL on the existing remote rather than adding a new one. SSH URLs start with git@github.com.
Make sure your public key is already on your GitHub account. Otherwise the next push fails with permission denied (publickey).
Can VS Code connect to GitHub Enterprise Server?
Yes. Open a local checkout of the repository and follow the sign-in prompt.
The GitHub Pull Requests and Issues extension works with GitHub Enterprise Server too, but you have to configure it for your server first.
Can GitHub CLI handle authentication for VS Code?
GitHub’s documentation says gh auth login can handle authentication over either HTTPS or SSH. Since VS Code runs your installed Git, I’d still do one clone from the terminal to confirm the login works before trusting it inside the editor.
Which Git version does GitHub require?
GitHub states that no minimum Git version is necessary, though version 1.7.10 has proven a comfortable stable baseline on many platforms.
Old releases are still a known cause of HTTPS cloning errors, so just install the current one from the Git website.
Disconnecting VS Code From GitHub on a Shared Machine
On a shared or borrowed computer, removing the remote isn’t enough. The remote, the sign-in, and the stored credentials are kept in different places, and each one has to be cleared separately.
Git: Remove Remote only drops the local connection. It leaves the hosted repository and your local commits intact, and the same documentation says nothing about credentials, so whoever uses the machine next may still be able to push as you.
- Revoke the token or SSH key in GitHub settings
- Sign out from the Accounts icon, then review Manage Trusted Extensions
- Clear the credential helper entry, then run Git: Remove Remote
Do the revocation first. It works from any browser, which matters if the laptop is already out of reach. Signing out and reviewing extension access are both behind the account icon at the bottom of the activity bar.
One catch with revoking. Deleting a token also deletes any deploy key that token was used to create, so check whether some automation depends on one before you delete it.
Position verified against the VS Code and GitHub documentation as of November 2026.
- How to Choose a Digital Transformation Consulting Partner - November 30, 2026
- Is Notepad++ Safe? Official Download, Updates, CVEs - November 29, 2026
- How to Evaluate an AI Code Reviewer on Your Own Pull Requests - November 29, 2026



