Connect to GitHub

Two doors: the editor and the terminal

Before GitHub accepts a push from your computer, it needs to authenticate you — a fancy word for "prove you're really you". And here's the part that trips people up: there are two separate doors. Signing in to VS Code covers everything you click inside the editor. The moment you run git push or git pull in a terminal, that's the second door — and GitHub no longer accepts your account password there. You'll set up both once, then never think about it again.

Sign in inside VS Code

If you don't have a GitHub account yet, sign up free at github.com. Then connect VS Code so pushing, pulling and Publish to GitHub "just work":

  • In VS Code, click the Accounts icon at the very bottom-left (the little person), then Sign in with GitHub.
  • A browser window opens — approve the request, and you're connected.

That's door one done. VS Code now handles credentials for anything you do through the Source Control panel. Next: the terminal.

Option A — HTTPS + a Personal Access Token

A Personal Access Token (PAT) is a long random string that acts as a password just for Git. Create one on GitHub under Settings → Developer settings → Personal access tokens → Fine-grained tokens → Generate. When Git asks for a password during a push, paste the token instead of your real password. A credential helper — a small program that stores logins for Git — saves it so you only do this once.

Remember your token after the first push

Terminal
$ git config --global credential.helper manager
$ # Windows: manager   macOS: osxkeychain   Linux: cache or store
In VS Code
  1. When VS Code is signed into GitHub it handles this for you
  2. You only deal with tokens when using the raw terminal

On Windows, Git Credential Manager ships with the Git installer — this line just makes sure it's switched on.

Tip: a token is a password — treat it like one. Never commit it to a repo, paste it in chat, or share it. If one leaks, delete it on GitHub and generate a fresh one.

Option B — SSH keys

An SSH key is a pair of files that proves your identity automatically — no passwords after setup. Generate one, add the public half to GitHub (Settings → SSH and GPG keys), then clone using the SSH URL (git@github.com:you/project.git).

Create and copy an SSH key

Terminal
$ ssh-keygen -t ed25519 -C "you@example.com"
$ # press Enter for the defaults, then copy the PUBLIC key:
$ cat ~/.ssh/id_ed25519.pub
In VS Code
  1. Paste the copied key into GitHub → Settings → SSH and GPG keys → New SSH key

Only ever share the .pub (public) file. The private key — the one without .pub — never leaves your computer.

The shortcut: gh auth login

Don't fancy juggling tokens or keys by hand? Install the official GitHub CLI (gh, from cli.github.com) and let one command do the whole dance — it opens your browser, you click approve, and it wires up your terminal credentials for you.

One command, done

Terminal
$ gh auth login
$ # choose: GitHub.com -> HTTPS -> Login with a web browser
In VS Code
  1. This is a terminal command — run it via Terminal → New Terminal
  2. Inside the editor, the Accounts sign-in above already covers you

This is the easiest route on a fresh machine — no manual token or key juggling.

Escape hatch: seeing the error "Support for password authentication was removed"? That's GitHub refusing your account password at the terminal door. Jump to Fix GitHub Login Errors for the step-by-step fix.

That's it — both doors open. From here on, Git talks to GitHub without asking who you are.

Up next: put the connection to work — send your commits up and bring changes down in Push & Pull.

FAQ

Frequently Asked Questions

What is a Personal Access Token (PAT) and why do I need one?
GitHub no longer accepts your account password when you push over HTTPS. Instead you create a Personal Access Token (GitHub → Settings → Developer settings) and paste it as the password, or set up SSH keys. A credential helper saves it so you only enter it once.
Should I use HTTPS or SSH for GitHub?
Both work. HTTPS with a PAT is the simplest way to start. SSH keys avoid typing credentials after a one-time setup — generate one with ssh-keygen and add the public key to GitHub.
Do I need to sign in to both VS Code and the terminal?
They're two separate doors. The Accounts sign-in covers everything inside the editor, but git push from a terminal needs its own credentials — a PAT, an SSH key, or one gh auth login. Set up both once and you never think about it again.
Where does Git remember my GitHub login?
A credential helper stores it after your first successful push — Git Credential Manager on Windows, the keychain on macOS. SSH keys live in ~/.ssh. If a saved login goes stale, see Fix GitHub Login Errors.