How to Connect VSCode to GitHub Easily

Summarize this article with:
Your code deserves better than living on one machine.
Learning how to connect VSCode to GitHub takes about 10 minutes and changes how you work with code forever.
Version control becomes automatic. Collaboration becomes possible. Backup happens with every push.
Visual Studio Code’s built-in Git integration makes the whole process straightforward. No third-party tools needed.
This guide walks you through installing Git, configuring your credentials, signing into GitHub, cloning repositories, and pushing your first changes.
By the end, you’ll have a complete development workflow connecting your local code editor to your remote repository.
Works on Windows, macOS, and Linux.
How to Connect VSCode to GitHub

Connecting VSCode to GitHub is the process of linking your code editor to a remote repository for version control, collaboration, and code backup.
You need this when working on team projects, contributing to open source, or simply keeping your codebase safe in the cloud.
This guide covers 6 steps requiring 10-15 minutes and basic familiarity with terminal commands.
Prerequisites
Before you start, make sure you have the following ready:
- Git version 2.39 or later installed on your system
- Visual Studio Code version 1.85 or later
- A GitHub account (free tier works fine)
- Stable internet connection
- Basic understanding of command line operations
Missing Git? You can download it from git-scm.com for Windows, macOS, or Linux.
Not sure what VSCode is? It’s Microsoft’s free code editor that handles everything from front-end development to back-end development.
Step 1: How Do You Install and Verify Git on Your Computer?
Download Git from the official website, run the installer for your operating system, then verify the installation by checking the version number in your terminal.
The expected result is a version output like git version 2.43.0.
Action
Windows: Download from git-scm.com > Run installer > Accept defaults > Finish
macOS: Open Terminal > Run xcode-select --install or use brew install git
Linux (Ubuntu): Open Terminal > Run sudo apt-get install git
Verification
Open your terminal and type:
git --version
You should see something like git version 2.43.0.
No version number? The installation failed. Try again or check your PATH settings.
Purpose
Git is the source control system that tracks changes in your code.
VSCode uses Git under the hood for all repository operations. Without Git installed locally, the GitHub integration won’t work.
Step 2: How Do You Configure Git with Your GitHub Credentials?
Set your username and email address using Git’s global configuration commands so every commit you make gets properly attributed to your GitHub account.
These credentials get stored in your system’s .gitconfig file.
Action
Open your terminal (or open terminal in VSCode) and run these commands:
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
Replace the values with your actual GitHub username and the email linked to your GitHub account.
Verification
Confirm your settings with:
git config --list
Look for user.name and user.email in the output.
Wrong email? Your commits won’t link to your GitHub profile. Double-check it matches exactly.
Purpose
Every commit in Git carries author information.
This is part of proper source control management. GitHub uses this data to display who made each change in the commit history.
Without correct credentials, your contributions won’t show up on your GitHub profile.
Step 3: How Do You Sign into GitHub from VSCode?
Click the Accounts icon in VSCode’s Activity Bar, select “Sign in to Sync Settings,” choose GitHub, then complete the OAuth authorization in your browser to connect your account.
VSCode displays a confirmation message when authentication succeeds.
Action
1. Activity Bar (left side) > Click Accounts icon (person silhouette at bottom)
2. Select “Sign in to Sync Settings” > Choose “Sign in with GitHub”
3. Browser opens > Click “Authorize Visual-Studio-Code”
4. Return to VSCode > Confirm “You are signed in” notification
Purpose
This establishes token-based authentication between VSCode and GitHub.
Once connected, you can clone private repositories, push changes, and sync settings across devices.
Step 4: How Do You Clone an Existing GitHub Repository in VSCode?
Open the Command Palette, run “Git: Clone,” paste your repository URL, select a local folder, and VSCode downloads the entire project with its commit history.
Action
1. Press Ctrl+Shift+P (Windows/Linux) or Cmd+Shift+P (macOS)
2. Type “Git: Clone” > Press Enter
3. Paste the repository URL: https://github.com/username/repo-name.git
4. Choose destination folder > Click “Select Repository Location”
5. Click “Open” when prompted to open the cloned repository
Purpose
Cloning creates a local copy of a remote repository on your machine.
You get all files, branches, and the full commit history. This is how most developers start working on existing projects or contribute to open source.
Step 5: How Do You Initialize a New Repository and Connect It to GitHub?
Open a project folder in VSCode, click “Initialize Repository” in the Source Control panel, then use “Publish to GitHub” to create a new remote repository and push your code.
Action
1. File > Open Folder > Select your project directory
2. Activity Bar > Click Source Control icon (branch symbol)
3. Click “Initialize Repository” button
4. Click “Publish to GitHub” in the Source Control panel header
5. Choose “Publish to GitHub Public Repository” or “Private Repository”
6. Select which files to include > Click “OK”
Purpose
Repository initialization creates a .git folder that enables version control for your project.
Publishing to GitHub sets up the remote origin automatically. Your local and remote repositories stay connected for future sync operations.
Step 6: How Do You Stage, Commit, and Push Changes to GitHub?
Stage modified files using the plus icon, write a descriptive commit message, click the checkmark to commit, then click “Sync Changes” to push your code to the remote repository on GitHub.
Action
1. Make changes to any file in your project
2. Source Control panel > Hover over changed file > Click “+” to stage
3. Type commit message in the text field (e.g., “Add login feature”)
4. Click checkmark icon or press Ctrl+Enter to commit
5. Click “Sync Changes” button (or cloud icon with arrows)
Purpose
Staging selects which changes go into your next commit. The commit message documents what changed and why.
Pushing uploads your commits to GitHub, making them available to collaborators. This workflow is central to any software development process using Git.
Verification
Confirm everything works by checking these three things:
- GitHub repository page: Visit github.com/username/repo-name and verify your files appear
- Commit history: Source Control panel > Three dots menu > View History shows your commits
- Status bar: Bottom-left of VSCode shows branch name and sync status (cloud icon)
All three check out? Your VSCode-GitHub connection is working.
Troubleshooting
Authentication Failed Error
Issue: VSCode shows “Authentication failed” when pushing or pulling.
Solution: Accounts icon > Sign out > Sign in again. If that fails, create a new personal access token in GitHub Settings > Developer settings > Personal access tokens.
Remote Repository Not Found
Issue: Error message says repository doesn’t exist or access denied.
Solution: Check the repository URL for typos, verify the repo exists on GitHub, confirm you have access (for private repos).
Push Rejected Due to Remote Changes
Issue: Push fails because someone else pushed changes first.
Solution: Command Palette > “Git: Pull” > Resolve any merge conflicts > Commit resolved files > Push again.
Git Not Recognized
Issue: Terminal says “git is not recognized as a command.”
Solution: Git isn’t in your system PATH. Reinstall Git and check “Add to PATH” during installation. Restart VSCode after.
Related Processes
Once your VSCode and GitHub connection works, explore these related workflows:
- Branch management: Create feature branches for isolated development
- Pull requests: Use GitHub Pull Requests extension for code review inside VSCode
- GitLens extension: See who changed each line and when
- Continuous integration: Connect GitHub Actions to run tests on every push
- Continuous deployment: Automate app deployment from your repository
Working with Python? Learn how to run Python in VSCode or how to debug Python for a complete development setup.
Need better code formatting? Check out how to use Prettier in VSCode or learn how to format code automatically.
FAQ on How To Connect VSCode To GitHub
Do I need to install Git separately to use GitHub in VSCode?
Yes. VSCode requires Git installed on your system to perform any version control operations.
Download Git from git-scm.com, run the installer, then restart VSCode. The Source Control panel won’t function without it.
How do I know if VSCode is connected to GitHub?
Click the Accounts icon (person silhouette) in the Activity Bar. Your GitHub username appears if connected.
The status bar at the bottom also shows branch sync status with a cloud icon when linked to a remote repository.
Can I connect multiple GitHub accounts to VSCode?
VSCode supports one GitHub account at a time. Switch accounts through Accounts icon > Sign out > Sign in with different credentials.
For managing multiple accounts, configure SSH keys with different hosts in your .ssh/config file.
Why does VSCode keep asking for my GitHub password?
Your authentication token expired or the credential manager lost your login.
Fix this by signing out and back in through VSCode’s Accounts menu. On Windows, check Git Credential Manager is installed properly.
What is the difference between cloning and initializing a repository?
Cloning downloads an existing GitHub repository to your computer with all its commit history and branches.
Initializing creates a new Git repository from scratch in a local folder. Use clone for existing projects, initialize for new ones.
How do I push code to GitHub for the first time?
Initialize your repository, stage files with the plus icon, write a commit message, and click “Publish to GitHub.”
VSCode creates the remote repository automatically. Choose public or private visibility during this step.
Can I use VSCode with GitHub without the command line?
Yes. VSCode’s Source Control panel handles clone, commit, push, pull, and branch operations through its graphical interface.
The settings.json file lets you customize Git behavior without touching terminal commands.
Why is my push to GitHub failing?
Common causes: expired credentials, no remote origin set, or remote has newer commits than your local branch.
Pull changes first with “Git: Pull” from the Command Palette, resolve any merge conflicts, then push again.
How do I connect an existing local project to GitHub?
Open the folder in VSCode, initialize the repository through Source Control, then click “Publish to GitHub.”
VSCode handles creating the remote repository and setting up the remote origin connection automatically.
Is it safe to store my GitHub credentials in VSCode?
VSCode uses your operating system’s secure credential storage. Windows uses Credential Manager, macOS uses Keychain.
OAuth tokens get encrypted and stored safely. Avoid saving passwords in plain text configuration files.
Conclusion
You now know how to connect VSCode to GitHub and have a working setup for code collaboration.
The six steps covered Git installation, credential configuration, GitHub sign-in, repository cloning, initialization, and pushing changes.
This workflow forms the foundation of modern software development.
Every commit you make builds your commit history. Every push keeps your work safe on a remote server.
Branch management and pull requests come next. These enable team workflows and proper software configuration management.
Consider adding the GitLens extension for detailed blame annotations. The GitHub Pull Requests extension brings code review directly into your web development IDE.
Start small. Commit often. Push regularly.
Your development workflow just got a serious upgrade.
- Top Mobile App Development Tools to Try - January 12, 2026
- How Product Teams Build Credit Education Into Apps - January 12, 2026
- How to Delete a Project in PyCharm Easily - January 11, 2026







