VS Code Integration
Connect GitHub to VS Code so you can stage, commit, and push without touching the terminal. Plus GitLens — the extension that turns every line of code into an audit trail.
Why bother with VS Code's Git UI?
The terminal commands — git add, git commit, git push — work perfectly. You'll use them throughout this program. But for day-to-day work, VS Code's built-in Source Control panel gives you something the terminal doesn't: you can see exactly what changed before you commit it.
Instead of typing git diff and reading through green and red text in the terminal, VS Code shows you two versions of the file side by side. The left shows what you had before. The right shows what you have now. Changed lines are highlighted in context. You can see whether you're committing what you think you're committing.
This matters more as projects get larger. When you've changed 12 files in one session, the visual diff is the difference between confident commits and "I think that's right."
The Source Control panel
The Source Control panel is Git built directly into VS Code. You don't install anything — it's there from day one.
To open it: Click the branching-paths icon in the left sidebar (it looks like a small branch with two forks, the third icon from the top). Or press Ctrl+Shift+G on Windows / Cmd+Shift+G on Mac.
What you see in the Source Control panel
When you open a project folder that contains a Git repository (i.e., one you've cloned from GitHub or initialized with git init), the Source Control panel shows:
Changes — a list of every file that has been modified since your last commit. Each file shows:
- The filename
- The type of change:
M(modified),U(untracked — a new file Git hasn't seen before),D(deleted) - A small icon: clicking the
+next to a file stages it (equivalent togit add filename)
Staged Changes — files you've staged using the + button. These are what will be included in your next commit.
Commit message box — at the top of the Source Control panel, there's a text field labeled "Message". This is where you type your commit message.
The checkmark button — clicking the checkmark (✓) at the top of the Source Control panel creates the commit. This is equivalent to git commit -m "your message".
Viewing a diff in VS Code
Click on any file in the Changes list. VS Code opens a split view:
- Left side (red highlights): the file as it was before your changes
- Right side (green highlights): the file as it is now
- Each changed line is highlighted in context with the surrounding unchanged code
This is your "review before you commit" moment. Get into the habit of clicking through your changed files before every commit. You'll catch mistakes you'd otherwise ship.
Signing in to GitHub from VS Code
Signing in connects VS Code to your GitHub account. This enables you to push and pull without the terminal ever asking for your PAT, and unlocks features in the GitHub Pull Requests extension.
Open the Accounts menu
In the VS Code left sidebar, at the very bottom, there's a person-icon (accounts) and a gear icon (settings). Click the person icon (accounts).
A menu appears with an option: Sign in with GitHub to use GitHub Pull Requests and Issues. Click it.
If you've already installed the GitHub Pull Requests and Issues extension, VS Code may also show a sign-in prompt directly in the sidebar panel.
Authorize in the browser
VS Code opens your browser and takes you to a GitHub authorization page. It says something like:
"VS Code wants to access your GitHub account"
Click the green Authorize Visual-Studio-Code button.
Your browser shows a confirmation: "You can now close this tab and return to VS Code."
VS Code confirms the sign-in
Switch back to VS Code. The accounts menu now shows your GitHub username instead of the "Sign in" option. You're connected.
Staging, committing, and pushing from VS Code
Once your project is open and VS Code is signed in to GitHub, here's the complete workflow without touching the terminal:
Make changes to your files
Edit any file in your project. As soon as you save, it appears in the Source Control panel under "Changes" with an M next to it.
Review your changes
Click on the file name in the Changes list. The diff view opens. Read through what changed. Confirm it's what you intended.
Stage the files you want to commit
Click the + icon next to individual files to stage just those files. Or click the + next to the word "Changes" (the heading) to stage everything at once.
Staged files move from "Changes" to "Staged Changes".
Write your commit message
Click into the text field at the top of the Source Control panel (the one that says "Message (Ctrl+Enter to commit)"). Type your commit message:
Commit
Press Ctrl+Enter (Windows) or Cmd+Enter (Mac). Or click the checkmark (✓) button at the top of the Source Control panel.
The staged files disappear from the panel — your commit is created locally.
Push to GitHub
After committing, the Source Control panel shows a small sync icon with a number (e.g., "↑1") indicating you have 1 commit ready to push. Click the sync button, or click the three-dots menu (...) at the top of the Source Control panel and select Push.
VS Code pushes your commit to GitHub. The sync indicator clears.
github.com/your-username/your-repo) and click on the file you just edited. Confirm your latest commit message appears at the top of the file history. If it does, the push worked correctly.The GitHub Pull Requests and Issues extension
This extension is already installed as part of your VS Code setup. It adds a GitHub icon to the left sidebar (looks like the GitHub logo — a cat silhouette). Clicking it opens a panel showing:
- Pull requests assigned to you
- Pull requests you've created
- Issues assigned to you
For now, this is most useful for reviewing pull requests directly inside VS Code without switching to the browser. When you start working on team projects, you'll use this to see what your teammates have submitted for review.
GitLens — the extension that shows why code exists
GitLens is already installed as part of your VS Code setup. It's one of the highest-value extensions for understanding a codebase.
Blame annotations
Open any file in VS Code. Move your cursor to any line. GitLens shows a faint annotation at the end of the line — something like:
This is called a blame annotation — it tells you who wrote that specific line, when, and in what commit. Without GitLens, you'd need to run git blame filename in the terminal and read through output that's hard to navigate.
For CA professionals: think of this as an audit trail per line of code. Every line in every file has a record of who wrote it and why.
Commit history in the file
Click the GitLens icon in the left sidebar (a small branching icon, below the GitHub icon). GitLens shows several views:
- File History — every commit that touched the current file, in order. Click any commit to see exactly what that commit changed.
- Line History — the history of the specific line your cursor is on.
- Repositories — an overview of all your repositories and their branches.
Hover details
Hover over the blame annotation at the end of any line. A popup appears showing the full commit message, the date, and a link to view the full commit on GitHub. This makes it possible to understand the context of any piece of code without ever leaving VS Code.
Terminal vs VS Code GUI — which to use?
Both work. Use whichever feels natural.
| Situation | Recommendation |
|---|---|
| Quick single-file commit | VS Code Source Control panel — faster |
| Reviewing changes before committing | VS Code Source Control panel — visual diff is much clearer |
| Complex operations (rebase, reset, cherry-pick) | Terminal — more control, clearer error messages |
| You're already in the terminal | Just use the terminal — no need to switch |
| Explaining to someone else | VS Code — easier to show |
The terminal gives you more power and control. The VS Code panel gives you better visibility. Most developers use both depending on the task.
You don't have to choose. During this program, practice both. Run the terminal commands a few times until you understand what they do. Then use the VS Code panel for day-to-day work. Knowing both means you can switch to the terminal when VS Code's GUI doesn't have what you need.