Git and Source Control in VS Code
Cloning, branching, staging, committing, pushing, and pulling from VS Code.
Listen
Transcript
Alex: Welcome back. Today we're moving Git out of the browser and into VS Code, where you can clone a repo, edit files, stage changes, commit, push, pull, and open the path toward a pull request.
Jamie: This is the moment where Git starts feeling real, right? Not just buttons on GitHub.com, but a local copy on your own machine.
Alex: Exactly. This supports Challenge 10, Go Local, where you clone your private Learning Room repository, create or use a learn/<username> branch, make one commit, push it, and use that work as evidence. Then Challenge 11 builds on it by opening a Day 2 pull request from that pushed branch and reading the PR in VS Code.
Jamie: And just to be very clear, the Learning Room repository is the one GitHub Classroom created for each learner. It is not the facilitator template repository.
Alex: Right. Use the private repo URL that looks like https://github.com/<workshop-org>/learning-room-<your-username>.git. Also, the shortcuts are mostly Ctrl on Windows and Linux, and Cmd on Mac, so Ctrl+Shift+P becomes Cmd+Shift+P, Ctrl+Shift+G becomes Cmd+Shift+G, and Ctrl+Enter becomes Cmd+Enter.
Jamie: Let's start with cloning, because that word sounds simple until you have three different tools offering to do it.
Alex: Cloning means making a full local copy of a Git repository. In VS Code, the most reliable path is the Command Palette: press Ctrl+Shift+P, run Git: Clone, paste the repository URL, choose a folder you can find again, and then open the cloned repository when VS Code asks.
Jamie: So VS Code is still using Git underneath, but it gives you prompts instead of making you remember the whole command.
Alex: Yes. The terminal version is git clone followed by the repository URL. The GitHub CLI version is gh repo clone owner/name, which is shorter and can handle GitHub authentication nicely once gh is signed in. VS Code also has a Start Page clone button, and GitHub.com has a Code button where you can copy the URL.
Jamie: What should a screen reader user expect while the clone is happening?
Alex: VS Code usually shows a progress notification. NVDA often reads it automatically, and if nothing seems to happen, you can run Notifications: Focus Notification Toast from the Command Palette. When the clone finishes, open Explorer with Ctrl+Shift+E and confirm you hear files such as README.md and folders such as docs.
Jamie: And after cloning, you might only see main locally, even if there are branches on GitHub.
Alex: Yes. A fresh clone checks out the default branch, often main. In the terminal, git branch -a lists local branches and remote-tracking branches like remotes/origin/learn/yourname. The star marks your current branch, and git switch learn/yourname or git checkout learn/yourname can create a local branch that follows the one on GitHub.
Jamie: The chapter also gives a low-stakes practice clone with the Sci-Fi Themes repo, which is helpful if you want to rehearse before touching your Learning Room work.
Alex: That's a good warm-up. You can clone with gh repo clone owner/name, cd into the folder, and open it in VS Code with code . if the code command is installed.
Alex: Once the repository is open, the Source Control view becomes your main Git dashboard in VS Code.
Jamie: That's the branch-looking icon in the Activity Bar, and the shortcut is Ctrl+Shift+G, or Cmd+Shift+G on Mac.
Alex: When it opens, you get the commit message input near the top, then groups of files such as Changes and Staged Changes. A changed file might be modified, added, deleted, renamed, or untracked. You can open a file's diff, stage it with the plus button, or use the context menu with Shift+F10.
Jamie: I like that the panel separates what changed from what is ready to commit. That reduces the mystery.
Alex: Git is tracking three areas. The working tree is the folder you are editing. The staging area is the set of changes you have selected for the next commit. The repository is Git's saved history after you commit.
Jamie: So the file states are untracked for a new file Git is not tracking yet, modified for a tracked file that changed, and staged for a change that is queued for the next commit.
Alex: Exactly. In the terminal, git status gives the same overview, git status -s gives a compact one-letter view, git diff shows unstaged changes, and git diff --staged shows what is ready to commit. Those command cards in the chapter are worth keeping nearby because they give you another way to verify what VS Code is showing.
Jamie: Branches are where a lot of people get nervous. What is the practical version?
Alex: A branch is a named line of work. For Challenge 10, you either switch to your existing learn/<username> branch or create it if it does not exist yet. In VS Code, use the Command Palette and run Git: Checkout to... for an existing branch, or Git: Create Branch... for a new one.
Jamie: And naming matters because maintainers and facilitators read those names later.
Alex: Yes. A name like learn/yourname or docs/improve-welcome is easier to understand than random-test. After you switch, the status bar shows the current branch. You can focus the status bar to hear it, and you can also run git branch --show-current.
Jamie: What happens when you switch branches?
Alex: VS Code updates the files in your working tree to match that branch. If you have uncommitted changes that would be overwritten, Git will stop and ask you to commit, stash, or discard them first. In the CLI, git switch -c branch-name creates and switches, git switch branch-name switches, git branch lists local branches, and git branch -a includes remote-tracking branches.
Jamie: And after a pull request is merged, deleting the branch is cleanup, not part of making the contribution real.
Alex: Right. You can delete a merged local branch with git branch -d branch-name, and delete a remote branch with git push origin --delete branch-name. Use force deletion only when you are certain the work is no longer needed.
Alex: Staging is the part of Git that lets you choose exactly what goes into a commit.
Jamie: Why not just commit everything that changed?
Alex: Sometimes that is fine, but staging gives you control. Maybe you fixed a typo and also started a bigger edit that is not ready. You can stage one file, stage all changes, or stage only selected lines or chunks, which Git often calls hunks.
Jamie: That is especially useful in workshop practice because a small commit is easier to explain and easier to review.
Alex: In VS Code, use the plus button next to one file to stage that file, or the plus button on the Changes group to stage everything. For line or chunk staging, open the diff and use the stage controls for the selected change. In the CLI, git add path stages one file, git add . stages current folder changes, and git add -p walks you through hunks interactively.
Jamie: And if you stage the wrong thing?
Alex: You can unstage it. In VS Code, use the minus button in Staged Changes. In the terminal, git restore --staged path removes it from the staging area without deleting your edit. Then check again with git status or by reading the Source Control groups.
Jamie: What about throwing changes away? That feels risky.
Alex: It should feel serious. Discard only when you are sure you do not need the edit. VS Code can discard one file or all unstaged changes, while git restore path does the same in the terminal. If you might need the work later, stash it instead; and if you truly want to remove a file from the repository, use Git Delete in VS Code or git rm path so the deletion is tracked and can be committed.
Jamie: Now we have changes staged. What makes a good commit?
Alex: A commit is a saved snapshot plus a message. A good subject line is short, specific, and written like an action, such as docs: improve welcome.md introduction. Many teams use a prefix like docs, fix, chore, or feat, followed by a colon and a plain-language summary.
Jamie: And the commit message input is at the top of Source Control.
Alex: Yes. Type the message there, then press Ctrl+Enter, or Cmd+Enter on Mac. Screen readers usually announce the Source Control state changing afterward because the staged files disappear. That is your signal that the commit was created locally.
Jamie: Local is the key word there.
Alex: Exactly. A commit on your computer is not on GitHub yet. In the terminal, the equivalent is git commit -m followed by your message. You can also use git commit without -m to write a longer message in an editor, or git commit -am for tracked files only, but beginners should be careful because that skips untracked new files.
Alex: Pushing sends your local commits to GitHub.
Jamie: So if I commit and then close my laptop, GitHub does not know about that commit until I push.
Alex: Correct. In VS Code, run Git: Push from the Command Palette, or use the sync and publish controls in the Source Control area. If the branch is new, VS Code may say Publish Branch. That creates or connects the branch on GitHub, often called origin, so your local branch has a remote tracking branch.
Jamie: Remote tracking branch is one of those phrases that sounds bigger than it is.
Alex: It means your local branch knows which branch on GitHub it normally pushes to and pulls from. In the CLI, the first push for a new branch is often git push -u origin branch-name. After that, git push is usually enough because Git remembers the relationship.
Jamie: Pulling is the opposite direction, then?
Alex: Mostly, yes. Pulling downloads commits from GitHub and integrates them into your current branch. Technically, git pull is git fetch plus a merge by default. If you want to see what changed before integrating, run git fetch, then git status or git log.
Jamie: When would git pull --rebase come up?
Alex: Use it when your local branch and the GitHub branch both have new commits, and you want your local commits replayed on top of the latest remote commits for a cleaner history. It is common on personal feature branches, but be careful on branches other people are also using. If a conflict appears during rebase or pull, stop, read the conflicting files, resolve them, then continue the operation.
Jamie: And if push fails, the usual reason is that GitHub has commits you do not have yet.
Alex: Right. Run git fetch, check git status, pull or pull with rebase if appropriate, resolve any conflicts, and then push again. For forked projects, GitHub.com may also offer a Sync fork button, and the terminal version is to add an upstream remote once, fetch upstream, merge or rebase the default branch, and push the updated branch back to your fork.
Jamie: Challenge 11 starts right after that push, because now the branch exists on GitHub and can become a pull request.
Alex: Yes. On GitHub.com, use Compare and pull request if the banner appears, or open Pull requests, choose New pull request, set base to main, compare to your branch, and include plain text like Closes #XX so the PR links to the challenge issue. If you prefer the web workflow for a small edit, you can still edit directly on GitHub.com, commit in the browser, and open a PR there, but Challenge 10 is about practicing the local path.
Jamie: Once work exists in history, how do you look back without getting lost?
Alex: VS Code has a Timeline view for a file. You can open it from the Explorer sidebar or through the Command Palette, and it shows recent saves and Git commits related to that file. Opening a commit lets you inspect what changed.
Jamie: And Git blame is the line-by-line history tool, right?
Alex: Yes. Blame shows which commit and author last changed each line. It is not about blaming a person; it is about finding context. In the terminal, git log shows repository history, git log -- path shows history for one file, git log -p includes patch details, git blame path shows line history, and git show commit-hash displays a specific commit.
Jamie: Conflicts are another kind of history lesson, but less friendly.
Alex: A merge conflict happens when Git cannot safely combine two edits to the same area. VS Code marks the file as conflicted and offers actions such as accept current, accept incoming, accept both, or compare changes. Do not just pick a button blindly; read the file and make the final content correct.
Jamie: The accessible diff view helps because you can move through changes in a more structured way than searching for conflict markers by hand.
Alex: Yes. Use the diff viewer, review one hunk at a time, save the resolved file, stage it, and complete the merge or rebase. If you realize you are in the wrong operation, git merge --abort can back out of a merge, and git rebase --abort can back out of a rebase.
Jamie: We touched stash earlier, but it deserves one more pass because it solves a very real problem: I changed files, and now I need to switch tasks.
Alex: Stash temporarily shelves uncommitted work. In VS Code, use the Command Palette for Git: Stash, then later Git: Apply Stash or Git: Pop Stash. Apply restores the changes and keeps the stash entry; pop restores the changes and removes the stash entry.
Jamie: The terminal version is git stash push -m with a message, git stash list, git stash show, git stash apply, and git stash pop.
Alex: Exactly. If you need to include new untracked files, use git stash push -u. You can drop one stash when you are done, or clear all stashes, but clear is a careful command because it removes every stash entry.
Jamie: And then there is reflog, the emergency tool.
Alex: Reflog records where your local branch tips and HEAD have been. If you deleted a branch or moved away from a commit, git reflog can help you find the old commit hash. The safer recovery move is usually to create a new branch at that hash, using git branch recovered-name hash, before doing anything destructive.
Jamie: But reflog is local. It is not a GitHub backup service.
Alex: Right. It exists on your machine and eventually expires entries. For everyday work, use steady habits: git status before acting, git branch --show-current before pushing, git fetch before assuming you are up to date, and clear PR text like Closes #XX.
Jamie: There are also alternatives if VS Code is not the best fit for a specific moment.
Alex: GitHub Desktop offers a visual Git interface. GitHub CLI gives commands like gh repo clone, gh pr create, gh pr view, and gh pr checkout. The Git CLI gives the most direct commands: clone, switch, add, commit, push, pull, fetch, status, log, restore, stash, and reflog.
Jamie: So the expected result for Challenge 10 is not a giant feature. It is evidence that the local workflow happened: the right branch name, a meaningful commit, a pushed branch, and PR metadata that links back to the issue.
Alex: Exactly. If you get stuck, confirm the repository URL, confirm you are on the intended branch, run git status, fetch before pushing, and ask for help with the exact message Git gave you. Small, verifiable steps make this workflow much less mysterious.
Workshop Content
Companion Podcast and Transcript
Use audio and transcript companions to review concepts in a conversational format.
Git and Source Control in VS Code
Companion audio: this episode reinforces key ideas and may not be a word-for-word reading of this page.
Open audio file (external) Full transcript source (external)
Transcript preview
Alex: Welcome back. Today we're moving Git out of the browser and into VS Code, where you can clone a repo, edit files, stage changes, commit, push, pull, and open the path toward a pull request.
Jamie: This is the moment where Git starts feeling real, right? Not just buttons on GitHub.com, but a local copy on your own machine.
Alex: Exactly. This supports Challenge 10, Go Local, where you clone your private Learning Room repository, create or use a learn/<username> branch, make one commit, push it, and use that work as evidence. Then Challenge 11 builds on it by opening a Day 2 pull request from that pushed branch and reading the PR in VS Code.
Jamie: And just to be very clear, the Learning Room repository is the one GitHub Classroom created for each learner. It is not the facilitator template repository.
Git & Source Control in VS Code
Listen to Episode 12: Git and Source Control in VS Code - a conversational audio overview of this chapter. Listen before reading to preview the concepts, or after to reinforce what you learned.
Related appendices: Appendix E: Advanced Git | Appendix D: Git Authentication | Appendix H: GitHub Desktop Authoritative sources: VS Code Docs: Source Control | GitHub Docs: Using Git | GitHub Accessibility Lab: CLI Guide
Managing Repositories, Branches, and Changes Accessibly
Day 2, Block 1-2 Material
This guide covers all Git operations in VS Code: cloning repositories, navigating the Source Control panel with screen readers, branch management, staging changes (including individual lines), push/pull operations, viewing file history with Timeline, resolving merge conflicts, and stash management.
Prerequisites: VS Code Setup & Accessibility Basics, Working with Pull Requests, Merge Conflicts
Mac keyboard shortcuts: Throughout this chapter, all
Ctrl+shortcuts useCmd+on Mac, andAlt+shortcuts useOption+. Common equivalents:Ctrl+Shift+G→Cmd+Shift+G,Ctrl+Shift+P→Cmd+Shift+P,Ctrl+Enter→Cmd+Enter,Ctrl+S→Cmd+S.
Workshop Recommendation (Chapter 14 / Challenge 10)
Chapter 14 is the first local Git workflow chapter with hands-on repository management. It supports Challenge 10: Go Local.
- Challenge count: 3
- Time per challenge: under 10 minutes each
- Evidence: PR metadata, branch names, and committed changes
- Pattern: clone, branch, edit, commit, push, PR
Challenge 10 Practice Set
- Clone your Learning Room repository - clone your private Learning Room repo to your local machine using VS Code.
- Create a branch and make one commit - check out (or create) your
learn/<username>branch, edit a file, stage, write a clear commit message, and commit locally. - Push and open a linked PR - push your branch and open a PR in your Learning Room repo that references your Challenge 10 or Day 2 PR issue.
CLI best practices for getting started
Even when you are working in VS Code, these CLI habits improve reliability:
- Check current state before action: run
git status. - Keep branch context explicit: run
git branch --show-current. - Verify remote alignment before pushing: run
git fetchthengit status. - Confirm PR linkage in plain text (
Closes #<number>) before opening or updating the PR. - Avoid undocumented or unverified convenience flags; use stable commands with clear output.
Practice 10.1 Step-by-Step: Clone Your Learning Room Repository
Goal: Get a local copy of your Learning Room repository on your machine using VS Code.
Where you are working: VS Code desktop (or github.dev if you cannot install desktop VS Code).
Your Learning Room repo is the same repo you have been working in all of Day 1 -- the private copy of learning-room-template that GitHub Classroom created for you. Cloning it locally lets you practice the full local Git workflow on a codebase you already know.
Do not clone Community-Access/learning-room-template for this challenge. That template is maintained by facilitators. Clone your own private Learning Room repository, the one whose URL looks like https://github.com/<workshop-org>/learning-room-<your-username>.git.
You do not need a GitHub organization or organization-level permissions to complete this workflow. If GitHub asks for authentication, sign in with your own GitHub account. If GitHub says you do not have access to the repo, confirm that you are using your private Learning Room URL and ask a facilitator for help.
- Open VS Code. If no folder is open, you should see the Welcome tab.
- Open the Command Palette:
Ctrl+Shift+P(Mac:Cmd+Shift+P). - Type
git cloneand select Git: Clone. - VS Code asks for a repository URL. Paste your Learning Room repo URL (it looks like
https://github.com/<workshop-org>/learning-room-<your-username>.git). You can copy this from the green Code button on your repo's GitHub page. - Press
Enter. - A file browser dialog opens asking where to save the clone. Choose a folder you can find easily (for example,
DocumentsorDesktop). Press Select as Repository Destination. - VS Code clones the repository. When it finishes, a notification appears asking "Would you like to open the cloned repository?" Activate Open.
- Verify the clone worked: press
Ctrl+Shift+E(Mac:Cmd+Shift+E) to open Explorer. Your screen reader should announce the file tree with files likeREADME.mdand thedocs/folder.
Screen reader tip: After step 6, VS Code shows a progress notification. NVDA reads this automatically. If you hear nothing for 30 seconds, open the Command Palette and run Notifications: Focus Notification Toast to check status.
You are done when: Your Learning Room repo folder is open in VS Code and you can see the docs/ folder along with README.md in the Explorer panel.
After cloning: check what branches exist. A fresh clone only checks out the default branch (
main), but the remote may have other branches you created earlier on GitHub.com (such as yourlearn/<username>branch). Rungit branch -ain the terminal (Ctrl+`) to see all branches -- local and remote:git branch -aYou will see output like:
* main remotes/origin/HEAD -> origin/main remotes/origin/main remotes/origin/learn/yournameThe
*marks your current branch. Lines starting withremotes/origin/are branches on GitHub that you can check out locally withgit checkout learn/yournameorgit switch learn/yourname.
Practice 10.2 Step-by-Step: Create a Branch and Commit
See also: Chapter 13: How Git Works explains the three areas (working directory, staging, repository) that make commits meaningful.
Goal: Check out (or create) a properly named branch, edit a file, stage the change, and commit with a clear message.
Where you are working: VS Code with your cloned Learning Room repository open.
- Open the Command Palette:
Ctrl+Shift+P(Mac:Cmd+Shift+P). - If your
learn/<username>branch already exists on the remote (because you created it during Day 1), typegit checkoutand select Git: Checkout to..., then picklearn/<your-username>. If the branch does not exist yet, typegit create branchand select Git: Create Branch... and enterlearn/<your-username>. - The status bar at the bottom of VS Code now shows your branch name instead of
main. Your screen reader announces the branch name when you focus the status bar. - Open the Explorer (
Ctrl+Shift+E) and navigate to thedocs/folder. Open any file mentioned in your Challenge 10 issue (for example,docs/welcome.md). - Make one small, meaningful edit. For example, add a new sentence, fix a typo, or improve a description. Save the file with
Ctrl+S(Mac:Cmd+S). - Open the Source Control panel:
Ctrl+Shift+G(Mac:Cmd+Shift+G). Your screen reader announces "Source Control" and shows your changed file under "Changes." - Navigate to your changed file in the Changes list. Press
Enteror activate the+(Stage Changes) button next to the filename. The file moves from "Changes" to "Staged Changes." - Move focus to the Message input box at the top of the Source Control panel. Type a clear commit message, for example:
docs: improve welcome.md introduction - Press
Ctrl+Enter(Mac:Cmd+Enter) to commit. The staged changes disappear, which means your commit succeeded.
Screen reader tip: In the Source Control panel, use arrow keys to navigate between changed files. Each file announces its name and change status (modified, added, deleted). The + button is announced as "Stage Changes" when you Tab to it.
You are done when: Your commit appears in the Source Control panel's history (no more staged or unstaged changes visible) and the status bar still shows your branch name.
Practice 10.3 Step-by-Step: Push and Open a Linked PR
Goal: Push your branch to GitHub and open a PR in your Learning Room repo that references your challenge issue.
Where you are working: VS Code (for the push) and GitHub.com (for the PR).
- Open the Command Palette:
Ctrl+Shift+P(Mac:Cmd+Shift+P). - Type
git pushand select Git: Push. If VS Code asks to publish the branch (because it is new), confirm by selecting OK or Publish Branch. - Wait for the push to complete. VS Code shows a progress notification. When done, the sync indicator in the status bar should show no pending changes.
- Open your browser and navigate to your Learning Room repository on GitHub.
- GitHub usually shows a yellow banner: "yourname recently pushed to learn/yourname." Activate the Compare & pull request button in that banner.
- If you do not see the banner, activate the Pull requests tab, then activate New pull request. Set the base branch to
mainand the compare branch to yourlearn/<your-username>branch. - In the PR title, write a descriptive title (for example: "docs: improve welcome.md introduction").
- In the PR description, type
Closes #XX(replaceXXwith your Challenge 10 or Day 2 PR issue number). Because the issue lives in the same repo as the PR, you only need the short#XXform. - Activate the Create pull request button.
Screen reader tip: The "Compare & pull request" banner is a standard link element near the top of the repository page. If your screen reader does not find it, use the heading navigation to jump to the Pull Requests tab instead.
Same-repo linking: Because your challenge issue and your PR live in the same repository, the short form Closes #XX is enough -- GitHub automatically resolves the issue number to a closure link. (If you ever open a PR in a different repo, you would use the full Closes <owner>/<repo>#XX form, which works exactly the same way.)
You are done when: Your PR appears on the Pull requests tab of your Learning Room repo, shows your branch name, and the description contains the Closes #XX reference to your challenge issue.
Completing Challenge 10: Submit Your Evidence
Open your assigned Challenge 10 issue in your Learning Room repo and post a completion comment:
Challenge 10 completed:
- Repository cloned: <my Learning Room repo>
- Branch name: learn/<yourname>
- Commit message: [your commit message]
- PR number: #[your PR number]
- PR links to issue: yes (Closes #XX in description)
Close your Challenge 10 issue when your branch is pushed and the PR is open.
Expected Outcomes
- Student can clone a repository using VS Code Command Palette.
- Student can create or check out a named branch following the workshop naming convention.
- Student can navigate the Source Control panel, stage files, and commit with a descriptive message.
- Student can push a branch and open a PR with same-repo issue linking.
If You Get Stuck
- Command Palette does not open? Confirm you are in VS Code (not the browser) and press
Ctrl+Shift+P(Mac:Cmd+Shift+P). - Source Control panel is empty? You may not have saved your file yet. Press
Ctrl+Sto save, then check again. - Push fails with authentication error? Open Command Palette, run
Git: Fetchto test your connection. If it fails, runGitHub: Sign Infrom Command Palette. - Branch name wrong? Open Command Palette, run
Git: Rename Branch...to fix it before pushing. - Cannot find the "Compare & pull request" banner on GitHub? Navigate to Pull requests tab and create the PR manually (step 6 above).
Closes #XXnot linking? Make sure the format is exactlyCloses #XXwith a single space and no extra characters. The keyword is case-insensitive but must be one ofCloses,Fixes, orResolves.- Ask facilitator to verify your clone location, branch name, and help with one push.
- Finished but not sure you did it right? Compare your work against the Challenge 10 reference solution.
Continue learning: The GitHub Skills course Introduction to Git walks through commits, branches, and merges in an interactive, self-paced format. See Appendix Z for the full catalog.
Learning Moment
Local Git operations give you full control and immediate feedback. You can see your changes, review them, and fix mistakes before they reach GitHub. The clone-branch-edit-commit-push-PR cycle you just completed is the daily workflow of every open source contributor. And now your Copilot Chat has custom sci-fi loading phrases as a bonus.
Learning Pattern Used in This Chapter
- Clone once to get a local copy of the project.
- Branch before editing (never work directly on
main). - Make small, focused edits with clear commit messages.
- Push and open a PR that links to an issue for traceability.
- Verify each step before moving to the next.
About Learning Cards
Throughout this chapter, each major operation includes learning cards - expandable sections showing how to accomplish the same task from multiple perspectives. Open the card that matches how you work:
The following table describes each learning card type and who it is for.
| Card | Who it is for |
|---|---|
| Visual / mouse users | Sighted users navigating with a mouse or trackpad |
| Low vision users | Users working with zoom (200%+), magnification, high contrast themes, or large cursors |
| Screen reader users (NVDA / JAWS) | Windows users navigating with NVDA or JAWS in Browse/Virtual mode |
| Screen reader users (VoiceOver) | macOS users navigating with VoiceOver |
| GitHub.com web interface | Browser-only workflow - no local tools required |
| CLI (git / gh) | Terminal commands for Git and GitHub CLI - predictable text output, scriptable |
You do not need to read every card. Pick the one or two that match your setup and skip the rest.
Table of Contents
- Cloning a Repository in VS Code
- The Source Control Panel - Complete Walkthrough
- Branch Management
- Staging Changes - Files, Lines, and Chunks
- Committing with Screen Readers
- Push and Pull Operations
- Discarding Changes
- Timeline View - File History and Blame
- Resolving Merge Conflicts in VS Code
- Stash Management
- Emergency Recovery - git reflog
- Alternative Git Interfaces
1. Cloning a Repository in VS Code
Tool Cards: Clone a Repository (Day 2)
VS Code Desktop (primary for Day 2):
Ctrl+Shift+P> Git: Clone > paste the HTTPS URL > choose a folder > Open.
github.dev (web editor):
No clone needed. Press . on any GitHub repository page to open it instantly.
GitHub Desktop:
- File > Clone Repository > paste URL or select from your account > Clone.
Git CLI (terminal):
git clone https://github.com/owner/repo.git && cd repo
GitHub CLI:
gh repo clone owner/repo && cd repo
Three ways to clone a repository
Method 1: Command Palette (Recommended for Screen Readers)
- Open Command Palette:
Ctrl+Shift+P(Mac:Cmd+Shift+P) - Type "git clone"
- Select "Git: Clone"
- Paste the repository URL (example:
https://github.com/community-access/accessibility-agents.git) - Press
Enter - Choose a local folder where the repository should be cloned
- VS Code asks: "Would you like to open the cloned repository?" - select "Open"
Screen reader navigation
- The Command Palette is a searchable list - type to filter,
Up/Down Arrowto navigate results - The folder picker is a standard file dialog - navigate with
Arrowkeys,Enterto select
Method 2: Start Page Clone Button
- Open VS Code (no folder open)
- The Start page appears
- Navigate to "Clone Git Repository" button - press
Enter - Paste repository URL →
Enter - Choose destination folder
- Open when prompted
Screen reader note: The Start page is keyboard-accessible. Tab to navigate between "New File," "Open Folder," and "Clone Repository" buttons.
Method 3: From GitHub.com
- On any GitHub repository page, click the green "Code" button
- Copy the HTTPS URL (recommended) or SSH URL
- Open VS Code →
Ctrl+Shift+P(Mac:Cmd+Shift+P) → "Git: Clone" - Paste URL →
Enter - Choose destination → Open
Learning Cards: Cloning a Repository
Low vision users (zoom, high contrast)
Cloning works the same as the Command Palette method above. A few tips for zoomed or magnified displays:
- The Command Palette (
Ctrl+Shift+P) appears at the top-center of VS Code and scales with your zoom level - it remains visible even at 200%+ zoom. - When the folder picker dialog opens, it may extend beyond your visible area at high zoom. Use
Alt+Up Arrowto navigate up in the folder tree andEnterto select. The dialog title bar shows your current location. - After cloning, the Explorer panel (
Ctrl+Shift+E) shows the file tree. At high zoom, useCtrl+-to temporarily reduce zoom if the tree is hard to scan, thenCtrl+=to restore. - If you use a high contrast theme (Settings:
Ctrl+,then search "color theme"), file status colours in the Explorer (green for added, yellow for modified) may be subtle. Enable Editor Decorator Colors or rely on the Source Control panel (Ctrl+Shift+G) where status letters (M, A, D) are shown as text.
GitHub.com web interface (no local tools needed)
If you cannot install Git or VS Code, you can work directly in the browser:
- Navigate to the repository on GitHub.com
- Press
.(period) to open github.dev - a browser-based VS Code editor - The full repository opens in an editor with file tree, search, and editing
- Changes are committed directly to GitHub from the browser
Alternatively, for quick edits:
- Navigate to any file on GitHub
- Press
Eto open the file editor - Make changes and commit from the web editor
Note: github.dev does not support terminal commands or local Git operations. For full Git workflows (branching, staging individual lines, stash), use desktop VS Code.
CLI (git / gh)
Clone from your terminal using either standard Git or GitHub CLI:
# Standard Git clone
git clone https://github.com/Community-Access/vscode-sci-fi-themes.git
cd vscode-sci-fi-themes
# GitHub CLI clone (shorter syntax, handles auth automatically)
gh repo clone Community-Access/vscode-sci-fi-themes
cd vscode-sci-fi-themes
# Clone into a specific folder
git clone https://github.com/Community-Access/vscode-sci-fi-themes.git ~/projects/themes
# Clone only the default branch (faster for large repos)
gh repo clone Community-Access/vscode-sci-fi-themes -- --single-branch
# Verify the clone
git status
git remote -v
Screen reader advantage: Terminal output is plain text. After cloning, git status confirms you are on the default branch with a clean working tree.
Why HTTPS over SSH for this workshop: HTTPS works immediately with no setup. SSH requires key generation and configuration (see Appendix D: Git Authentication for SSH setup).
Try It Now: Clone the Sci-Fi Themes Repo
To make your first clone meaningful and fun, try cloning the VS Code Sci-Fi Thinking Phrases repository:
Repository URL: https://github.com/community-access/vscode-sci-fi-themes.git
This repo contains custom loading phrases for GitHub Copilot Chat from three sci-fi universes:
- Star Trek — Engage warp drive and run diagnostics
- The Hitchhiker's Guide — Consult the Infinite Improbability Drive
- Star Wars — Read the ripples in the Force
Why Clone This?
- It's a real, working repository with multiple files to explore
- You'll see a practical use of cloning (customizing your personal VS Code setup)
- After cloning, you can pick a theme and apply it to your
settings.json - When you open Copilot Chat, you'll see your custom phrases appear!
Quick Start
- Clone:
Ctrl+Shift+P→ "Git: Clone" → paste URL above →Enter - Choose a destination folder and open when prompted
- Navigate to the
themes/folder and pick a.jsonfile (star-trek, hitchhikers, or star-wars) - Copy the
chat.agent.thinking.phrasessetting into your VS Codesettings.json - Reload VS Code:
Ctrl+Shift+P→ "Developer: Reload Window" - Open Copilot Chat (
Ctrl+Alt+I, or Chat: Open Chat from the Command Palette if your keymap differs) and ask a question - watch your custom phrases appear!
See CLONE-THIS-REPO.md in that repo for full instructions.
Web alternative (github.com)
If you prefer not to clone locally, you can work entirely on GitHub.com:
- Navigate to the repository on GitHub
- Click any file to view it, then click the pencil icon (Edit) to modify it directly in the browser
- GitHub automatically creates a branch and commit for your edit
- When you save, GitHub prompts you to open a pull request
This approach requires no local tools - just a browser. It works well for documentation changes and small edits. For larger changes, cloning to VS Code gives you a full editor with multi-file editing, Git staging, and the Accessible Diff Viewer.
GitHub CLI (gh) alternative
Clone a repository with one command:
# Clone using owner/name (no URL needed)
gh repo clone community-access/vscode-sci-fi-themes
# Clone and cd into the folder
gh repo clone community-access/vscode-sci-fi-themes && cd vscode-sci-fi-themes
# Open the cloned repo in VS Code
gh repo clone community-access/vscode-sci-fi-themes && code vscode-sci-fi-themes
2. The Source Control Panel - Complete Walkthrough
The Source Control panel (Ctrl+Shift+G - Mac: Cmd+Shift+G) is where all Git operations happen in VS Code. This section provides a complete screen reader walkthrough of every interactive element.
Opening the Source Control Panel
Shortcut: Ctrl+Shift+G (Mac: Cmd+Shift+G)
What opens
- A sidebar panel on the left side of VS Code
- Focus lands on the first interactive element (usually the commit message input or the first changed file)
Panel structure from top to bottom
Source Control title bar (heading level 2)
- Branch name displayed (example: "main" or "feature/add-documentation")
- View/More Actions button (three dots menu)
Commit message input (multi-line text field)
- Type your commit message here
- Announced as "Source Control Input, edit, multi-line"
Commit button (or "Publish Branch" if this is a new branch)
- Shortcut:
Ctrl+Enter(Mac:Cmd+Enter) when focused in the message input
- Shortcut:
Changes section (collapsible tree)
- Lists all modified files not yet staged
- Announced as "Changes, expanded" or "Changes, collapsed"
- Count shown (example: "Changes 3")
Staged Changes section (collapsible tree)
- Lists files staged for commit
- Empty if nothing staged yet
- Announced as "Staged Changes, expanded"
Merge Changes section (appears only during a merge)
- Lists files with conflicts
- See Section 9 for conflict resolution workflow
Screen Reader Navigation in the Source Control Panel
NVDA/JAWS
- The panel is a web-based tree view
- Use
Up/Down Arrowto navigate between items - Use
Right Arrowto expand a section (Changes, Staged Changes) - Use
Left Arrowto collapse a section - Use
Enterto open a file diff - Use
Spaceto stage/unstage a file (when focused on a file item)
VoiceOver
- Navigate with
VO+Arrowkeys VO+Spaceto activate (open diff or stage/unstage)- The panel is announced as a "group" containing lists
Key point: The Source Control panel is not a standard file tree. It's a specialized Git status view. Each changed file is an interactive item with a context menu.
What Each File Shows
When a file appears in the Changes or Staged Changes list, VS Code shows a status letter:
| Letter | Meaning |
|---|---|
| M | Modified - file exists and was changed |
| A | Added - new file, not in Git yet |
| D | Deleted - file was removed |
| R | Renamed - file was moved or renamed |
| U | Untracked - file exists but Git is ignoring it |
| C | Conflict - file has merge conflicts (see Section 9) |
Screen reader announcement: "docs/GUIDE.md, Modified" or "README.md, Added"
Context Menu Actions (Right-Click or Shift+F10)
When focused on any file in the Source Control panel:
| Action | What It Does |
|---|---|
| Open File | Opens the file in the editor (same as Enter) |
| Open Changes | Opens side-by-side diff view (same as Enter) |
| Stage Changes | Moves file from Changes → Staged Changes |
| Unstage Changes | Moves file from Staged Changes → Changes |
| Discard Changes | Dangerous - deletes your local edits, restores file to last commit |
| Stage Selected Ranges | Stage only specific lines (see Section 4) |
| Revert Selected Ranges | Discard changes to specific lines only |
Screen reader tip: Use Shift+F10 to open the context menu. Navigate options with Up/Down Arrow. Press Enter to select.
Learning Cards: Source Control Panel
Low vision users (zoom, high contrast)
The Source Control panel adapts well to zoom and high contrast settings:
- At high zoom (200%+): The panel may narrow. File names truncate but the status letter (M, A, D) remains visible at the end of each row. Hover over truncated names to see the full path in a tooltip.
- High contrast themes: Status colours are reinforced by the status letter (M/A/D/R/U/C), so you do not rely on colour alone. To switch to a high contrast theme:
Ctrl+Shift+Pthen type "Preferences: Color Theme" and select "High Contrast" or "High Contrast Light." - The commit message input is a multi-line text area. At high zoom it may appear narrow - it expands vertically as you type. Use
Ctrl+Enterto commit from anywhere in the input (notEnter, which adds a new line). - Diff views opened from the panel use red/green highlighting. In high contrast themes these use distinct border patterns instead of subtle colour shading. Press
F7to jump between change hunks rather than scrolling through large diffs visually. - Minimap: If the minimap (the narrow code preview strip on the right edge of the editor) is distracting at high zoom, disable it: Settings (
Ctrl+,) then search "minimap enabled" and uncheck it.
CLI equivalent: viewing Git status
The Source Control panel shows the same information as these terminal commands:
# See all modified, staged, and untracked files
git status
# Short format (one letter per file, compact)
git status -s
# See what is staged (ready to commit)
git diff --cached --name-only
# See what is modified but not staged
git diff --name-only
# See both staged and unstaged differences with content
git diff # unstaged changes
git diff --cached # staged changes
The letters match: M = modified, A = added, D = deleted, R = renamed, ?? = untracked.
3. Branch Management
Branches are how you organize work in Git. Every repository starts with a main or master branch. You create new branches for features, bug fixes, or experiments.
Viewing the Current Branch
Where it's shown
- Bottom-left corner of VS Code (status bar) - visual users see it immediately
- Source Control panel title bar
- Command Palette:
Ctrl+Shift+P(Mac:Cmd+Shift+P) → "Git: Show Git Output"
Keyboard access to status bar
- The status bar is not in the standard keyboard navigation flow
- Use the Command Palette for branch operations instead
Visual users: You can also click the branch name in the bottom-left status bar to open the branch picker directly.
Creating a New Branch
Command Palette method (recommended)
Ctrl+Shift+P(Mac:Cmd+Shift+P)- Type "git create branch"
- Select "Git: Create Branch..."
- Type the new branch name (example:
feature/improve-docs) - Press
Enter
VS Code:
- Creates the branch
- Switches to it automatically
- Your working files stay exactly as they were
Naming conventions
- Use lowercase with hyphens:
feature/add-timeline-guide - Avoid spaces and special characters
- Be descriptive:
fix/heading-hierarchynotfix1
Web alternative (github.com) - branch management
Create and switch branches without leaving your browser:
- On the repository page, click the branch dropdown (shows "main" by default)
- Type a new branch name in the search field
- Click "Create branch: your-branch-name from main"
- GitHub switches to the new branch immediately
- Any file edits you make in the browser will be on this branch
To switch between branches, click the branch dropdown and select the branch you want.
Git CLI alternative - branch management
Manage branches from your terminal:
# Create and switch to a new branch
git checkout -b feature/improve-docs
# List all branches
git branch -a
# Switch to an existing branch
git checkout main
# Delete a branch (after merging)
git branch -d feature/improve-docs
Switching Between Branches
Command Palette method
Ctrl+Shift+P(Mac:Cmd+Shift+P)- Type "git checkout"
- Select "Git: Checkout to..."
- A list of all branches appears
Up/Down Arrowto navigateEnterto switch
Screen reader announcement: "Branch: main" or "Branch: feature/add-timeline-guide"
What happens when you switch
- VS Code saves your current files
- Loads the files from the other branch
- If you have uncommitted changes, Git may block the switch (see "Stashing" in Section 10)
Deleting a Branch
After your PR is merged, you can delete the branch
Ctrl+Shift+P(Mac:Cmd+Shift+P)- Type "git delete branch"
- Select "Git: Delete Branch..."
- Choose the branch to delete from the list
- Confirm
Note: You cannot delete the branch you're currently on. Switch to main first.
Viewing All Branches
Command: Ctrl+Shift+P → "Git: Show Git Output" → Branch list appears
Alternative: Use the integrated terminal:
git branch # Local branches only
git branch -a # All branches (including remote)
Learning Cards: Branch Management
Low vision users (zoom, high contrast)
- Branch name in the status bar: The current branch name appears in the bottom-left corner of VS Code. At high zoom, the status bar may be partially off-screen. Use
Ctrl+Shift+Pthen type "Git: Checkout to..." to see and switch branches from the Command Palette instead. - Branch picker list: When you open the branch picker from the Command Palette, the list shows all available branches. At high zoom, long branch names may truncate. Type the first few characters to filter the list - the filter is instant.
- Visual branch indicators in the Explorer: Modified files on a branch show a coloured dot in the Explorer panel. In high contrast themes, these dots use distinct shapes or borders. The Source Control panel (
Ctrl+Shift+G) is more reliable for seeing which files changed on your branch.
Screen reader users (NVDA / JAWS on Windows)
Creating a branch
- Press
Ctrl+Shift+Pto open the Command Palette - Type "git create branch" - NVDA/JAWS announces results as you type
- Press
Enteron "Git: Create Branch..." - The input focus moves to a text field - type your branch name (e.g.,
feature/add-docs) - Press
Enter- VS Code creates and switches to the branch - NVDA/JAWS announces the new branch name in the status bar notification
Switching branches
- Press
Ctrl+Shift+P, type "git checkout" - Select "Git: Checkout to..."
- A list of branches appears - navigate with
Up/Down Arrow - Each item is announced as the branch name (e.g., "main", "feature/add-docs")
- Press
Enterto switch - VS Code reloads files for that branch - you hear a status bar update
Deleting a branch
- Switch to a different branch first (you cannot delete the branch you are on)
- Press
Ctrl+Shift+P, type "git delete branch" - Select "Git: Delete Branch..."
- Navigate the list to find the branch to delete, press
Enter
Screen reader users (VoiceOver on macOS)
Creating a branch
- Press
Cmd+Shift+Pto open the Command Palette - Type "git create branch" - VoiceOver announces filtered results
- Press
Returnon "Git: Create Branch..." - Type the branch name in the input field
- Press
Returnto create and switch
Switching branches
- Press
Cmd+Shift+P, type "git checkout" - Select "Git: Checkout to..."
- Use
VO+Down Arrowto navigate the branch list - Press
Returnto switch
Getting the current branch name
- Press
VO+Mto move to the menu bar, thenVO+Right Arrowto the status bar area - Or use the Command Palette:
Cmd+Shift+Pthen type "Git: Show Git Output" - the output pane includes the current branch
GitHub.com web interface
Create and switch branches without leaving your browser:
- On the repository page, find the branch dropdown button (shows "main" by default) - it is above the file table
- Click or activate the dropdown
- Type a new branch name in the search field
- Click "Create branch: your-branch-name from main" when it appears
- GitHub switches to the new branch immediately
- Any file edits in the browser will be on this branch
To switch between branches:
- Click the branch dropdown
- Select the branch you want - the page reloads with that branch's files
To delete a branch:
- Navigate to the repository's Branches page: click the branch count link (e.g., "3 branches") near the branch dropdown, or go to
github.com/owner/repo/branches - Find the branch
- Click the trash can icon next to it
CLI (git / gh)
Manage branches from your terminal:
# Create and switch to a new branch
git checkout -b feature/improve-docs
# Or use the newer 'switch' command
git switch -c feature/improve-docs
# List local branches (current branch marked with *)
git branch
# List all branches including remote-tracking
git branch -a
# Switch to an existing branch
git checkout main
# or
git switch main
# Delete a branch (safe - only if merged)
git branch -d feature/improve-docs
# Force delete a branch (even if not merged)
git branch -D feature/improve-docs
# Rename the current branch
git branch -m new-name
# Push a new branch to GitHub for the first time
git push -u origin feature/improve-docs
# Delete a remote branch
git push origin --delete feature/improve-docs
Using GitHub CLI:
# Create a branch linked to an issue (auto-names from issue title)
gh issue develop 42 --checkout
# List remote branches
gh api repos/{owner}/{repo}/branches --jq '.[].name'
4. Staging Changes - Files, Lines, and Chunks
Git has a two-step commit process:
- Stage the changes you want to include
- Commit those staged changes
This lets you commit only part of your work, leaving the rest for a later commit.
Staging an Entire File
Visual / mouse users
- Open Source Control:
Ctrl+Shift+G(Mac:Cmd+Shift+G) - Hover over a file in the "Changes" list - a + icon appears to its right
- Click the + to stage that file
- Or right-click a file → "Stage Changes"
Low vision users (zoom, high contrast)
- Open Source Control:
Ctrl+Shift+G(Mac:Cmd+Shift+G) - At high zoom, the + (stage), undo (discard), and open file icons may be small. Instead of hovering:
- Right-click any file in the Changes list to get a full-size context menu with "Stage Changes", "Discard Changes", and other options
- Or use
Ctrl+Shift+Pthen type "Git: Stage Changes" to stage the currently open file
- The file moves from "Changes" to "Staged Changes" - both section headings include a count (e.g., "Changes 2", "Staged Changes 1") so you can confirm the move without relying on colour alone.
- In high contrast themes, staged files show a distinct background or border in the Staged Changes section.
Screen reader users (NVDA / JAWS / VoiceOver)
- Open Source Control:
Ctrl+Shift+G(Mac:Cmd+Shift+G) - Navigate to the file in the "Changes" list
- Press
Ctrl+Enter(Mac:Cmd+Enter) to stage immediately
Alternative (keyboard shortcut)
- Focus the file → press
Space
Alternative (context menu)
- Focus the file → press
Shift+F10(Mac:Ctrl+Return) → select "Stage Changes"
What happens
- The file moves from "Changes" → "Staged Changes"
- A green "A" or "M" indicator appears
Staging Multiple Files at Once
Ctrl+Shift+G(Mac:Cmd+Shift+G) to open Source Control- Navigate to the "Changes" section heading
- Press
Shift+F10(Mac:Ctrl+Return) to open context menu on the section itself - Select "Stage All Changes"
All modified files move to "Staged Changes."
Staging Individual Lines or Chunks
This is one of Git's most powerful features: You can stage only specific lines of a file, leaving other changes unstaged.
Workflow
- Open Source Control:
Ctrl+Shift+G(Mac:Cmd+Shift+G) - Navigate to a file in "Changes"
- Press
Enterto open the diff view - The diff shows your changes side-by-side or inline
- Navigate to a changed line (use
Arrowkeys orF7for next hunk) - Press
Shift+F10(Mac:Ctrl+Return) to open context menu - Select "Stage Selected Lines"
Result: Only those lines are staged. The rest of the file remains in "Changes."
Use case for this workshop
- You fixed a typo and added a new section in the same file
- You want to commit the typo fix separately from the new content
- Stage only the typo fix lines, commit them with message "fix: typo in heading"
- Then stage the new section, commit with message "docs: add Timeline View guide"
Screen reader tip: In the diff view, press Alt+H to see Accessible Help for diff-specific keyboard shortcuts.
Web alternative (github.com) - editing files
On GitHub.com, there is no staging step. When you edit a file in the browser:
- Click the pencil icon on any file to open the web editor
- Make your changes
- Click "Commit changes" - GitHub creates the commit directly
- Choose to commit to the current branch or create a new branch and PR
This is the simplest workflow if you are making a focused change to one file. For multi-file changes, VS Code's staging system gives you more control.
Git CLI alternative - staging
Stage files from your terminal:
# Stage a specific file
git add docs/GUIDE.md
# Stage all changes
git add .
# Stage specific lines interactively
git add -p docs/GUIDE.md
# Git shows each change hunk and asks: stage this? (y/n/s/e)
# Unstage a file
git restore --staged docs/GUIDE.md
# Check what is staged vs unstaged
git status
Unstaging Files
Reverse the process
- Focus the file in "Staged Changes"
- Press
Ctrl+Enter(Mac:Cmd+Enter) orSpace - File moves back to "Changes"
Learning Cards: Staging Changes
Screen reader users
- In Source Control (
Ctrl+Shift+G), press+orSpaceon a file to stage it -- your screen reader announces the file moving from "Changes" to "Staged Changes" - To stage individual lines, open the file diff (
Enteron the file), select lines withShift+Up/Down, then use Command Palette: "Git: Stage Selected Ranges" - Press
Ctrl+Zin the Source Control panel to unstage the last staged file if you staged the wrong one
Low vision users
- Staged files appear under a separate "Staged Changes" heading with a green
+icon -- look for the section break in the Source Control panel - The inline diff view highlights added lines in green and removed lines in red; use
Ctrl+=to zoom if the colors are hard to distinguish - Right-click a file in the Source Control panel for a context menu with "Stage Changes", "Discard Changes", and "Open File" options
Sighted users
- Hover over a file in the Changes list to see
+(stage), curved arrow (discard), and file-open icons appear on the right - Click the
+icon next to "Changes" header to stage all files at once, or click+on individual files for selective staging - The Source Control badge number on the Activity Bar decreases as you stage and commit changes
5. Committing with Screen Readers
The Commit Workflow
Standard process
- Open Source Control:
Ctrl+Shift+G(Mac:Cmd+Shift+G) - Stage changes (see Section 4)
- Focus the commit message input (usually
TaborShift+Tabto reach it) - Type your commit message
- Press
Ctrl+Enter(Mac:Cmd+Enter) to commit
Learning Cards: Committing
Visual / mouse users
- Open Source Control (
Ctrl+Shift+G) - Stage your files (click the + icon next to each file, or click Stage All Changes above the Changes section header)
- Click in the "Message" text area at the top of the Source Control panel
- Type your commit message
- Click the Commit button (checkmark icon) or press
Ctrl+Enter - If nothing is staged, VS Code asks if you want to stage all changes and commit directly - click "Yes" if that is what you want
Low vision users (zoom, high contrast)
- The commit message input is at the top of the Source Control panel. At high zoom it may appear as a narrow rectangle - it expands vertically as you type.
- The Commit button may show only as a small checkmark icon at high zoom. Use
Ctrl+Enterfrom inside the message input instead - this is more reliable than finding the button visually. - After committing, the Staged Changes section clears. The count next to the section heading drops to 0, confirming the commit was recorded.
- If you need to see your recent commits, use the Timeline view (
Ctrl+Shift+E, navigate to the Timeline section at the bottom of Explorer) where each commit shows full message text at a readable size.
Screen reader experience
NVDA/JAWS
- The commit input is announced as "Source Control Input, edit, multi-line"
- You're automatically in Forms Mode - just start typing
- The input expands as you type (supports multi-line messages)
- Press
Ctrl+Enter(Mac:Cmd+Enter) to commit (notEnter, which adds a new line)
VoiceOver
VO+Tabto navigate to the inputVO+Shift+Downto interact- Type your message
Ctrl+Enterto commitVO+Shift+Upto stop interacting
Writing Good Commit Messages
See Culture & Etiquette: Writing Good Commit Messages for format guidance.
Quick reference
fix: correct heading hierarchy in GUIDE.md
Fixes #42
Format
- First line: type + colon + short summary (50 characters max)
- Blank line
- Optional body: detailed explanation
- Optional footer: "Fixes #123" to link to issue
Common types: feat:, fix:, docs:, style:, refactor:, test:, chore:
Git CLI alternative - committing
Commit from your terminal:
# Commit staged changes with a message
git commit -m "fix: correct heading hierarchy in GUIDE.md"
# Commit with a multi-line message (opens your editor)
git commit
# Stage all tracked files and commit in one step
git commit -am "docs: update screen reader instructions"
What Happens After Commit
- The "Staged Changes" section clears
- Your changes are now part of Git history
- The commit exists locally only - you must push to send it to GitHub (see Section 6)
6. Push and Pull Operations
Push sends your local commits to GitHub.
Pull downloads new commits from GitHub to your local repository.
Pushing Your Commits to GitHub
After committing locally
- Open Source Control:
Ctrl+Shift+G(Mac:Cmd+Shift+G) - Look for the "Publish Branch" button (if this is a new branch) or "Sync Changes" button
- Press
Enteron that button
Alternative: Command Palette
Ctrl+Shift+P(Mac:Cmd+Shift+P)- Type "git push"
- Select "Git: Push"
- VS Code pushes your commits to GitHub
Learning Cards: Push and Pull
Low vision users (zoom, high contrast)
- The Sync/Publish button appears in the Source Control panel header area. At high zoom it may display as a small cloud icon with an arrow. If you cannot find it, use the Command Palette (
Ctrl+Shift+Pthen type "Git: Push") - this is always reliable. - Progress indication: While pushing, VS Code shows a spinning icon in the status bar (bottom-left). At high zoom this may be off-screen. After pushing, run
Ctrl+Shift+Pthen "Git: Show Git Output" to read the push log as scrollable text. - Pull indicators: When your branch is behind the remote, the status bar shows a down-arrow with a number (e.g., "↓2" means 2 commits to pull). At high zoom, the Command Palette approach (
Ctrl+Shift+Pthen "Git: Pull") avoids needing to read the status bar. - Auto-fetch: Enable auto-fetch (Settings: search "git autofetch") so VS Code checks for remote changes every few minutes. This prevents surprise conflicts when you push.
Screen reader users (NVDA / JAWS on Windows)
Pushing
- After committing, press
Ctrl+Shift+P, type "git push", select "Git: Push" - NVDA/JAWS announces "Pushing..." in the status bar
- On success, a notification appears: "Successfully pushed" - if using NVDA, check
NVDA+Nto read recent notifications - For a new branch (first push), use "Git: Publish Branch" instead - this sets up the upstream tracking
Pulling
- Press
Ctrl+Shift+P, type "git pull", select "Git: Pull" - NVDA/JAWS announces "Pulling..." then the status changes
- If there are conflicts, the Source Control panel shows a "Merge Changes" section - navigate there with
Ctrl+Shift+GthenDown Arrow
Checking sync status
- Press
Ctrl+Shift+P, type "Git: Show Git Output" - The output pane opens with push/pull log messages in plain text
- Use
Up/Down Arrowto read line by line
Screen reader users (VoiceOver on macOS)
Pushing
- Press
Cmd+Shift+P, type "git push", select "Git: Push" - VoiceOver announces progress from the status bar
- On success, a notification toast appears - press
VO+F3to read the latest notification
Pulling
- Press
Cmd+Shift+P, type "git pull", select "Git: Pull" - VoiceOver announces when the pull completes
- If conflicts exist, navigate to Source Control (
Cmd+Shift+G) and review the Merge Changes section
Screen reader feedback
- NVDA/JAWS: Status bar announces "Pushing..." then "Pushed successfully" or an error message
- Check the Source Control panel for any error messages (they appear as banner notifications)
Git CLI alternative - push and pull
Push and pull from your terminal:
# Push commits to GitHub
git push
# Push a new branch for the first time
git push -u origin feature/improve-docs
# Pull changes from GitHub
git pull
# Fetch without merging (see what changed first)
git fetch
git log HEAD..origin/main --oneline
Web alternative (github.com) - push and pull
On GitHub.com, there is no push/pull step - your commits are saved directly to GitHub when you use the web editor. If you edited on a branch, your changes are already on GitHub. Simply open a pull request from that branch.
If your branch is behind main, look for the "Update branch" button on your PR page to pull in the latest changes.
What to do if push fails
- Error: "No upstream branch" → You need to publish the branch first (Command Palette → "Git: Publish Branch")
- Error: "Permission denied" → Check your authentication (see Appendix D: Git Authentication)
- Error: "Rejected - non-fast-forward" → Someone else pushed changes; you need to pull first
Pulling Changes from GitHub
When to pull
- Before you start work each day
- When GitHub shows your branch is behind the remote
- When preparing to merge a PR
How to pull
Ctrl+Shift+P(Mac:Cmd+Shift+P)- Type "git pull"
- Select "Git: Pull"
- VS Code fetches and merges remote changes
If there are conflicts: See Section 9.
Auto-fetch setting
- VS Code can check for remote changes automatically every few minutes
- Enable: Settings (
Ctrl+,- Mac:Cmd+,) → search "git autofetch" → set totrue
Syncing Your Fork with the Upstream Repository
When you fork a repository and the original (upstream) repository receives new commits, your fork gets out of date. Keeping your fork current prevents merge conflicts and ensures you're working with the latest code.
The GitHub "Sync fork" Button (Quickest Method)
For straightforward updates, GitHub has a built-in sync button:
- Navigate to your fork on GitHub
- On the repository page, look for the "This branch is N commits behind owner/repo:main" notice
- Activate the "Sync fork" button next to it
- GitHub automatically merges upstream changes into your fork's default branch
- Then pull those changes to your local clone:
Git: Pullfrom the Command Palette
Screen reader path
On your fork's main page:
→ H or 3 to find the sync notice heading
→ Tab to "Sync fork" button → Enter
→ "Update branch" in the dialog → Enter
Limitation: The GitHub sync button only syncs the default branch. For other branches, use the git method below.
Adding the Upstream Remote (One-Time Setup)
To sync locally using git, you first configure the upstream remote. This only needs to be done once per clone.
Step 1: Open the terminal in VS Code: Ctrl+` (backtick)
Step 2: Check your current remotes:
git remote -v
→ You should see "origin" pointing to YOUR fork
Step 3: Add the upstream remote:
git remote add upstream https://github.com/ORIGINAL-OWNER/ORIGINAL-REPO.git
Step 4: Verify:
git remote -v
→ You should now see both "origin" (your fork) and "upstream" (original)
Example for Accessibility Agents
git remote add upstream https://github.com/community-access/accessibility-agents.git
Fetching and Merging Upstream Changes
Once your upstream remote is configured:
# 1. Fetch all updates from upstream (does not change your files yet)
git fetch upstream
# 2. Make sure you are on your default branch
git checkout main
# 3. Merge upstream changes into your local branch
git merge upstream/main
# 4. Push the updated branch to your fork on GitHub
git push origin main
Via VS Code Command Palette
Ctrl+Shift+P → "Git: Fetch" → select "upstream"
Ctrl+Shift+P → "Git: Merge Branch" → select "upstream/main"
Ctrl+Shift+P → "Git: Push"
When Conflicts Occur During Sync
See also: Chapter 07: Merge Conflicts for a dedicated walkthrough of conflict resolution.
If you've made changes to the same files the upstream has changed, merge conflicts can occur during sync. The same conflict resolution flow applies - see Section 9 of this chapter.
Best practice: Always sync before starting new work on a fork. A quick git fetch upstream at the start of each session prevents conflicts from accumulating.
7. Discarding Changes
Discarding = permanently deleting your local edits. The file reverts to the state of the last commit. This is irreversible.
When to Discard
- You made experimental changes and they didn't work
- You want to start over from the last commit
- You accidentally edited the wrong file
How to Discard Changes
Single file
- Open Source Control:
Ctrl+Shift+G - Navigate to the file in "Changes"
- Press
Shift+F10for context menu - Select "Discard Changes"
- Confirm in the warning dialog (VS Code will ask "Are you sure?")
All changes
Ctrl+Shift+G- Navigate to the "Changes" section heading
Shift+F10for context menu- Select "Discard All Changes"
- Confirm (this affects every modified file)
Screen reader warning: VS Code shows a modal confirmation dialog. Navigate with Tab, select "Discard" or "Cancel" with Enter.
Learning Cards: Discarding Changes
Low vision users (zoom, high contrast)
- The discard icon (an undo arrow) appears when hovering over a file in the Changes list. At high zoom, right-click the file instead to get a full-size context menu with "Discard Changes."
- The confirmation dialog that appears is a modal - it dims the background. In high contrast themes, the dialog has a clear border. The "Discard" button is typically the focused (primary) button.
- For "Discard All Changes", right-click the "Changes" section heading to get the context menu.
- After discarding, the file disappears from the Changes list. Check the file count in the section heading to confirm (e.g., "Changes 2" becomes "Changes 1").
Screen reader users (NVDA / JAWS on Windows)
Single file
- Press
Ctrl+Shift+Gto open Source Control - Navigate to the file in the Changes section with
Down Arrow - Press
Shift+F10to open the context menu - Navigate to "Discard Changes" with
Down Arrow, pressEnter - A confirmation dialog appears - NVDA announces "Are you sure you want to discard changes" or similar
- Press
Tabto navigate between "Discard" and "Cancel", pressEnteron your choice
All files
- Navigate to the "Changes" section heading (announced as "Changes, expanded, N items")
- Press
Shift+F10, select "Discard All Changes" - Confirm in the dialog
Screen reader users (VoiceOver on macOS)
- Press
Cmd+Shift+Gto open Source Control - Use
VO+Arrowkeys to navigate to the file - Press
VO+Shift+Mto open the context menu (orCtrl+Return) - Navigate to "Discard Changes", press
VO+Space - In the confirmation dialog, use
VO+Right Arrowto reach the buttons,VO+Spaceto activate
CLI (git / gh)
Discard changes from your terminal:
# Discard changes to a specific file (restore to last commit)
git restore docs/GUIDE.md
# Discard all unstaged changes
git restore .
# Discard staged changes (unstage first, then restore)
git restore --staged docs/GUIDE.md
git restore docs/GUIDE.md
# Nuclear option: discard ALL changes (staged and unstaged)
git checkout -- .
# Preview what would be discarded before doing it
git diff # shows unstaged changes
git diff --cached # shows staged changes
Safety tip: Run
git diffbeforegit restoreto review what you are about to lose. Unlike VS Code's discard, there is no confirmation prompt in the terminal.
Safer Alternative: Stash Instead of Discard
If you're not sure whether you'll need these changes later, use stash (Section 10) instead of discard. Stash saves your changes temporarily without committing them.
Deleting a File from the Repository (Git Delete / git rm)
Git Delete removes a file from both your working directory AND Git's tracking. This is different from discarding changes - it permanently removes the file from the repository history going forward.
How to use
- Open the file you want to remove in the editor
Ctrl+Shift+P(Mac:Cmd+Shift+P)- Type "Git: Delete"
- Confirm the deletion
The file is staged for deletion - you still need to commit to record the removal.
When to use Git Delete vs. just deleting the file
- Simply deleting a file from Explorer leaves it as an "untracked deletion" in Git
- Using
Git: Delete(git rm) stages the deletion in one step - Use
git rmwhen you want to track the file removal as part of your next commit
Learning Cards: Deleting a File from the Repository
Visual / mouse users
- Right-click the file in the Explorer panel (
Ctrl+Shift+E) - Select "Delete" to delete from your file system
- The file appears in Source Control (
Ctrl+Shift+G) under Changes with a "D" (deleted) status - Stage and commit the deletion to record it in Git
Alternatively: Ctrl+Shift+P then "Git: Delete" removes the file and stages the deletion in one step.
Low vision users (zoom, high contrast)
- The easiest approach at high zoom is
Ctrl+Shift+Pthen type "Git: Delete" - this works on the currently open file and avoids finding small context menu targets. - After deletion, confirm in Source Control (
Ctrl+Shift+G) - the file appears with a "D" status letter. The "D" is text, not colour-only, so it works in all themes. - Stage and commit as normal.
Screen reader users (NVDA / JAWS / VoiceOver)
- Open the file you want to remove in the editor
- Press
Ctrl+Shift+P(Mac:Cmd+Shift+P), type "Git: Delete" - Select the command - the file is deleted and staged for removal
- Navigate to Source Control (
Ctrl+Shift+G) - the file is announced as "filename, Deleted" in the Staged Changes section - Write a commit message and press
Ctrl+Enterto commit the removal
NVDA/JAWS note: The file disappears from the Explorer tree. If you navigate there, you will no longer hear the filename.
GitHub.com web interface
- Navigate to the file on GitHub
- Click the three-dot menu ("...") in the file header
- Select "Delete file"
- Write a commit message describing why the file was removed
- Choose to commit directly or open a PR
- Click "Commit changes"
For screen reader users on GitHub: press Tab to navigate to the file actions menu, then Enter to open it.
CLI (git / gh)
# Remove a file and stage the deletion in one step
git rm docs/old-file.md
# Remove a file but keep it locally (stop tracking only)
git rm --cached docs/old-file.md
# Remove an entire directory
git rm -r old-folder/
# Commit the deletion
git commit -m "chore: remove outdated documentation file"
# Verify the file is no longer tracked
git status
8. Timeline View - File History and Blame
The Timeline view shows the Git history of the currently open file: every commit that touched this file, who made it, and when.
Opening Timeline View
Method 1: Explorer Sidebar
- Open Explorer:
Ctrl+Shift+E - At the bottom of the Explorer, there's a "Timeline" section
TaborArrowto navigate into Timeline- The list shows all commits affecting the currently open file
Method 2: Command Palette
- Open a file in the editor
Ctrl+Shift+P- Type "timeline"
- Select "View: Show Timeline"
What Timeline Shows
For each commit entry:
- Commit message (first line)
- Author name
- Relative time (example: "3 days ago" or "2 hours ago")
- Commit hash (short form, like
a3f2b9c)
Screen reader announcement: "docs: add Timeline Guide, Jeff, 2 days ago"
Viewing a Commit's Changes
- Navigate to a commit in the Timeline list
- Press
Enter - A diff view opens showing what changed in that specific commit
This is incredibly useful for understanding:
- When a particular line was added
- Why a section was removed
- What the file looked like at any point in history
Git Blame - Line-by-Line History
Git Blame shows who last modified each line of the file.
How to access
- Open a file in the editor
Ctrl+Shift+P- Type "git blame"
- Select "Git: Toggle Blame"
What appears
- Inline annotations next to every line (visually)
- Hover over a line to see commit details
For screen reader users
- The inline blame annotations can add noise
- Use Timeline view instead to see recent changes to the whole file
- Use
Ctrl+Fto search the Timeline list for a specific author or date
Useful blame settings (add to .vscode/settings.json or user Settings):
| Setting | Default | What It Does |
|---|---|---|
git.blame.ignoreWhitespace |
false |
When true, whitespace-only changes (reformatting) are excluded from blame - useful when code was reformatted without logic changes |
git.blame.editorDecoration.disableHover |
false |
When true, disables the hover tooltip on blame annotations - reduces screen reader noise if you find the blame decorations intrusive |
Learning Cards: Timeline and History
Low vision users (zoom, high contrast)
- Timeline panel location: It is at the bottom of the Explorer sidebar (
Ctrl+Shift+E). At high zoom you may need to scroll down in the Explorer to find it. If the Timeline section is collapsed, click the Timeline heading to expand it. - Reading commit entries: Each entry shows the commit message, author, and time. At high zoom, long commit messages may truncate. Click any entry to open the diff view, which shows the full message in the editor tab title.
- Diff view at high zoom: Red/green highlighting shows removed/added lines. In high contrast themes, changes use distinct borders or backgrounds. Press
F7to jump through changes with a visible highlight that is easier to track than scrolling. - Git Blame at high zoom: The inline blame annotations are small grey text at the end of each line. At high zoom they may overlap with code. Use Timeline view instead for a more readable list of who changed what.
Screen reader users (NVDA / JAWS on Windows)
Opening Timeline
- Press
Ctrl+Shift+Eto open Explorer - Press
Tabrepeatedly orDown Arrowto navigate past the file tree to the "Timeline" section - Press
Right Arrowto expand it if collapsed - Navigate commit entries with
Up/Down Arrow - Each entry is announced as: "commit message, author, time" (e.g., "docs: add Timeline Guide, Jeff, 2 days ago")
- Press
Enteron any entry to open its diff view
Reading a diff with screen reader
- In the diff view, press
Alt+F2to open the Accessible Diff Viewer - The Accessible Diff Viewer presents changes as a text list: each line shows
+(added),-(removed), or unchanged - Navigate with
Up/Down Arrowto read each line - Press
Escapeto close the Accessible Diff Viewer
Git Blame
- Open a file, press
Ctrl+Shift+P, type "Git: Toggle Blame" - Blame annotations appear inline - NVDA reads them when navigating lines
- To reduce noise, disable blame (repeat the toggle command) and use Timeline instead
Screen reader users (VoiceOver on macOS)
Opening Timeline
- Press
Cmd+Shift+Eto open Explorer - Use
VO+Down Arrowto navigate below the file tree to the Timeline section - Press
VO+Spaceto expand if collapsed - Navigate entries with
VO+Down Arrow - Press
VO+Spaceon a commit to open its diff
Accessible Diff Viewer
- In any diff view, press
Option+F2to open the Accessible Diff Viewer - Read changes line by line with
VO+Down Arrow - Press
Escapeto close
CLI (git / gh) - history and blame
# View commit history for the entire repo
git log --oneline
# View history for a specific file
git log --oneline docs/GUIDE.md
# View history with what changed in each commit
git log -p docs/GUIDE.md
# View who last changed each line (blame)
git blame docs/GUIDE.md
# Blame with short commit hashes and author
git blame --date=short docs/GUIDE.md
# Show a specific commit's changes
git show abc1234
# Show what changed between two commits
git diff abc1234..def5678
# Show commits by a specific author
git log --author="Jeff" --oneline
# Show commits in the last 7 days
git log --since="7 days ago" --oneline
Using GitHub CLI:
# View recent commits from the web
gh api repos/{owner}/{repo}/commits --jq '.[0:5] | .[] | .commit.message'
# View PR history
gh pr list --state all --limit 10
Screen reader advantage: git log --oneline and git blame produce clean, columnar text output. Read line by line with arrow keys in the terminal.
9. Resolving Merge Conflicts in VS Code
Merge conflicts happen when two people edit the same lines of a file. Git can't decide which version to keep, so it asks you to choose.
Prerequisite: Read Merge Conflicts for the underlying concepts. This section covers the VS Code-specific workflow.
How VS Code Displays Conflicts
When you open a file with conflicts, you see something like:
<<<<<<< HEAD
## Timeline View - File History
=======
## Timeline View - Git History and Blame
>>>>>>> feature/improve-timeline-guide
VS Code adds buttons above each conflict (visually):
- "Accept Current Change" (keeps HEAD version)
- "Accept Incoming Change" (keeps the other branch's version)
- "Accept Both Changes" (keeps both, one after the other)
- "Compare Changes" (opens side-by-side diff)
Screen Reader Workflow for Resolving Conflicts
The buttons are NOT accessible via keyboard. Use this method instead:
Identify the conflict markers:
<<<<<<<marks the start=======separates the two versions>>>>>>>marks the end
Read both versions:
- The section between
<<<<<<<and=======is your current branch (HEAD) - The section between
=======and>>>>>>>is the incoming branch (the branch you're merging)
- The section between
Decide what to keep:
- Delete the conflict markers (
<<<<<<<,=======,>>>>>>>) - Delete the version you don't want
- Or rewrite the section combining both versions
- Save the file
- Delete the conflict markers (
Stage the resolved file:
Ctrl+Shift+Gto open Source Control- The file appears in "Merge Changes" section
- Stage it (presses
Ctrl+EnterorSpace)
Commit the merge:
- Type commit message (or keep the auto-generated one: "Merge branch 'feature/...' into main")
Ctrl+Enter(Mac:Cmd+Enter) to commit
Using Accessible Diff for Conflict Review
Better approach: Use the Accessible Diff Viewer (F7) to navigate conflict hunks systematically.
- Open the conflicted file
- Press
F7to jump to the first conflict hunk - Press
Alt+F2to open Accessible View - Read both versions clearly
- Press
Escapeto return to editor - Manually edit to resolve
- Press
F7to jump to the next conflict - Repeat until all conflicts resolved
This gives you structured, hunk-by-hunk navigation instead of searching for markers manually
Aborting a Merge
If you want to cancel the merge and go back to before you started:
Ctrl+Shift+P- Type "git abort"
- Select "Git: Abort Merge"
Everything returns to the pre-merge state.
Learning Cards: Resolving Merge Conflicts
Screen reader users
- Press
F7in a conflict file to enter the Accessible Diff Viewer and step through conflicts hunk by hunk with announced change types - Conflict markers (
<<<<<<<,=======,>>>>>>>) are read aloud as you arrow through lines -- listen for these to identify conflict boundaries - After resolving all markers, stage the file with
Ctrl+Shift+Gthen navigate to it and press+, then commit to complete the merge
Low vision users
- VS Code highlights conflict regions with colored backgrounds: green for "Current Change" (yours) and blue for "Incoming Change" (theirs)
- The inline action buttons ("Accept Current", "Accept Incoming", "Accept Both") appear above each conflict -- they are visible at high zoom levels
- Use
Ctrl+Shift+Mto check the Problems panel for any remaining conflict markers you may have missed
Sighted users
- Look for the colored conflict blocks in the editor: green background = your version, blue background = incoming version
- Click "Accept Current Change", "Accept Incoming Change", or "Accept Both Changes" above each conflict for one-click resolution
- The Source Control panel shows a merge badge when conflicts exist -- it clears after you commit the resolution
10. Stash Management
Stash temporarily saves your uncommitted changes so you can switch branches or pull updates without committing half-finished work.
When to Use Stash
- You need to switch branches but have uncommitted changes
- You want to pull updates from GitHub but have local edits
- You want to save experimental work without committing it
Creating a Stash
Method 1: Command Palette
Ctrl+Shift+P- Type "git stash"
- Select "Git: Stash"
- Optionally type a stash message (helps you remember what's in it)
What happens
- Your uncommitted changes disappear from the editor
- The files revert to the last commit
- Your changes are saved in a hidden Git stash
- You can now switch branches or pull safely
Viewing Stashes
Command Palette
Ctrl+Shift+P- Type "git stash list"
- Select "Git: Show Stash"
Alternative: Integrated Terminal
git stash list
Output looks like:
stash@{0}: WIP on feature/docs: add Timeline guide
stash@{1}: WIP on main: fix typo
Applying a Stash
To restore your stashed changes
Ctrl+Shift+P- Type "git stash apply"
- Select "Git: Apply Latest Stash"
Or to apply a specific stash
Ctrl+Shift+P- Type "git stash pop"
- Select "Git: Pop Stash..."
- Choose which stash from the list
Difference between Apply and Pop
- Apply: restores changes and keeps the stash (you can apply it again later)
- Pop: restores changes and deletes the stash
Dropping a Stash
If you no longer need what's in a stash:
Ctrl+Shift+P- Type "git stash drop"
- Select "Git: Drop Stash..."
- Choose which stash to delete
Learning Cards: Stash Management
Visual / mouse users
- Open Source Control:
Ctrl+Shift+G - In the Source Control panel, there may be a "Stashes" section below Staged Changes (visible when stashes exist)
- Click a stash to see what it contains
- Right-click a stash to Apply, Pop, or Drop it
If the Stashes section is not visible, use the Command Palette: Ctrl+Shift+P then type "git stash" to access all stash commands.
Low vision users (zoom, high contrast)
- The Stashes section in the Source Control panel may be below the fold at high zoom. Scroll down in the panel, or use the Command Palette (
Ctrl+Shift+Pthen "git stash") which is always accessible regardless of zoom level. - Stash names in the Command Palette list are full text (e.g., "stash@{0}: WIP on feature/docs: add Timeline guide") and respect your font size settings.
- After applying a stash, your files reappear in the Changes section of Source Control. Check the file count to confirm.
Screen reader users (NVDA / JAWS on Windows)
Creating a stash
- Press
Ctrl+Shift+P, type "git stash" - Select "Git: Stash" - NVDA announces the result
- An input appears asking for a stash message - type something descriptive (e.g., "WIP: documentation changes for Timeline section")
- Press
Enter- your changes disappear from Source Control and are saved in the stash - NVDA announces the Source Control panel update (file counts drop to 0)
Applying a stash
- Press
Ctrl+Shift+P, type "git stash pop" - Select "Git: Pop Stash..."
- A list of stashes appears - navigate with
Up/Down Arrow - Each item is announced with the stash message you wrote
- Press
Enterto apply and delete the stash - Your changes reappear in the Changes section
Viewing stashes
- Press
Ctrl+Shift+P, type "git stash list" - Or in the terminal: type
git stash listand read the output line by line
Screen reader users (VoiceOver on macOS)
- Press
Cmd+Shift+P, type "git stash" - Select "Git: Stash" and provide a message
- Press
Return - To apply:
Cmd+Shift+P, type "git stash pop", select from the list withVO+Down Arrow, pressReturn
GitHub.com web interface
GitHub.com does not have a stash feature. Stash is a local Git operation only. If you need to save work-in-progress without committing on GitHub.com:
- Create a draft commit on a temporary branch
- Or use GitHub Codespaces (which runs a full VS Code environment in the browser and supports
git stashin the terminal)
CLI (git / gh) - stash commands
# Stash all uncommitted changes with a message
git stash push -m "WIP: documentation changes"
# Stash including untracked (new) files
git stash push -u -m "WIP: including new files"
# List all stashes
git stash list
# Show what a specific stash contains
git stash show stash@{0}
git stash show -p stash@{0} # with full diff
# Apply the most recent stash (keep stash)
git stash apply
# Apply and delete the most recent stash
git stash pop
# Apply a specific stash
git stash apply stash@{1}
# Delete a specific stash
git stash drop stash@{0}
# Delete ALL stashes (careful)
git stash clear
10b. Emergency Recovery - git reflog
git reflog is the safety net you reach for when something goes seriously wrong: an accidental hard reset, a lost branch, a rebase that destroyed commits you needed. It is the most underused recovery tool in Git.
What reflog records: Every time the HEAD pointer moves - from commits, resets, rebases, checkouts, merges - Git quietly records it in the reflog. These entries are kept for 90 days by default.
When to Use Reflog
| Scenario | What happened | Reflog solution |
|---|---|---|
| Deleted a branch by mistake | git branch -D feature/x |
Find the last commit SHA from reflog → recreate branch |
git reset --hard lost commits |
Moved HEAD to older commit | Find the SHA before the reset → reset back to it |
| Rebase went wrong | Commits appear lost | Find pre-rebase HEAD → reset to it |
| Accidentally force-pushed | Local history destroyed | Find the SHA from reflog → restore |
Reading the Reflog in VS Code Terminal
git reflog
Output looks like:
abc1234 HEAD@{0}: commit: Fix typo in README
bcd2345 HEAD@{1}: reset: moving to HEAD~1
cde3456 HEAD@{2}: commit: Add accessibility section
def4567 HEAD@{3}: checkout: moving from main to feature/docs
Each line: <SHA> HEAD@{N}: <what happened>
Screen reader tip: Run this in the integrated terminal (Ctrl+Backtick). The output is plain text - read line by line with ↓. You are looking for the SHA just before the action that caused the problem.
Recovering Lost Commits
If you need to restore a commit that has been lost
# Step 1 - Find the last good commit SHA in reflog
git reflog
# Step 2 - Preview what that commit looked like
git show abc1234
# Step 3a - Create a new branch at that point (safest)
git branch recovery/my-lost-work abc1234
# Step 3b - OR reset the current branch to that point
git reset --hard abc1234
Use
git branchovergit reset --hardwhen recovering - creating a branch is non-destructive; you keep both the current state and the recovered state, then decide which to keep.
Recovering a Deleted Branch
# Find the last commit on the deleted branch
git reflog | grep 'feature/deleted-branch-name'
# Recreate the branch at that SHA
git checkout -b feature/deleted-branch-name abc1234
Why Reflog Is Local-Only
Reflog records are stored in your local .git/ directory and are not pushed to GitHub. If your entire local clone is destroyed (hard drive failure, rm -rf), reflog cannot help - but GitHub retains the pushed commits in the remote history.
Workshop tip: If you run a reset or rebase during the workshop and lose something, immediately run git reflog before doing anything else. The recovery window is open as long as you haven't run git gc.
Learning Cards: Emergency Recovery
Screen reader users
- Run
git reflog --onelinein the terminal and arrow through the output -- each line announces a HEAD movement with its SHA and action description - Copy the SHA you want to recover to by selecting it in the terminal (
Shift+Arrow) then pressingCtrl+C, then rungit checkout -b recovery <SHA> - Reflog entries are kept for 90 days -- you have time to recover, so do not panic
Low vision users
git reflogoutput is columnar text: SHA on the left, action description on the right -- increase terminal font size withCtrl+=for readability- Each reflog entry starts with
HEAD@{N}where N is the number of steps back -- lower numbers are more recent - Use
git log --oneline --graphafter recovery to visually confirm the branch history looks correct
Sighted users
- Look for the SHA hash in the leftmost column of
git reflogoutput -- these are the restore points you can checkout or reset to - The action column (e.g., "commit:", "reset:", "checkout:") tells you what caused each HEAD movement
- After recovering with
git checkout -b, verify in the Source Control panel that the branch appears with the expected files
11. Alternative Git Interfaces
VS Code's Source Control panel is one way to use Git. These alternatives exist for different workflows.
GitHub Desktop
- Graphical Git client
- Download: desktop.github.com
- Strengths: Visual diff review, simpler branch management for beginners
- Screen reader support: Partial - keyboard navigation works for core flows but some visual-only elements exist
GitHub CLI (gh)
- Command-line interface for GitHub operations
- Install:
winget install GitHub.cli(Windows) orbrew install gh(macOS) - Strengths: Fast, scriptable, plain-text output (predictable for screen readers)
Common commands
gh repo clone owner/repo # Clone a repository
gh issue list # List issues
gh pr create # Create a PR interactively
gh pr list # List your PRs
gh pr view 14 # Read PR #14
See Culture & Etiquette for more gh examples.
Git CLI (Terminal)
- The standard Git command-line interface
- Included with VS Code (integrated terminal:
Ctrl+Backtick)
Common commands
git status # Show modified files
git add . # Stage all changes
git commit -m "message" # Commit with message
git push # Push to GitHub
git pull # Pull from GitHub
git log # View commit history
Screen reader tip: Terminal output is plain text - more predictable than GUI elements for some operations.
VS Code Keyboard Shortcuts - Git Operations Quick Reference
| Action | Shortcut |
|---|---|
| Open Source Control | Ctrl+Shift+G |
| Stage file | Ctrl+Enter (on file in Changes) |
| Unstage file | Ctrl+Enter (on file in Staged Changes) |
| Commit | Ctrl+Enter (in message input) |
| View file diff | Enter (on file in Source Control) |
| Next diff hunk | F7 |
| Previous diff hunk | Shift+F7 |
| Open Accessible Diff Viewer | Alt+F2 (in diff view) |
| Accessible Help | Alt+H (in any panel) |
| Open Timeline view | Ctrl+Shift+E → navigate to Timeline section |
| Integrated terminal | Ctrl+Backtick |
| Delete file from repo (git rm) | Ctrl+Shift+P → "Git: Delete" |
Try It: Clone, Branch, Commit
Time: 5 minutes | What you need: VS Code with Git configured
Do the complete Git workflow once, start to finish:
- Clone - Press
Ctrl+Shift+P, typeGit: Clone, pressEnter. Pastehttps://github.com/Community-Access/vscode-sci-fi-themes.gitand choose a folder. VS Code opens the repo. - Create a branch - Click the branch name in the status bar (bottom left) or press
Ctrl+Shift+P→Git: Create Branch. Name itchapter11/your-name. - Make a change - Open a theme file in the
themes/folder (for example,star-trek-settings.json). Add a new thinking phrase to the array. - Stage - Press
Ctrl+Shift+Gto open Source Control. Navigate to your changed file and pressEnterto stage it (or use the+button). - Commit - Tab to the message input, type
feat: add new thinking phrase, pressCtrl+Enter. - Push - Press
Ctrl+Shift+P→Git: Push.
You're done. You just completed the full Git cycle: clone → branch → edit → stage → commit → push.
What success feels like: Your change is on GitHub. You can verify by visiting the repository and switching to your branch. Every future contribution follows this same six-step pattern. And your Copilot Chat now has a custom sci-fi loading phrase you wrote.
Next: Chapter 15: Code Review
Back: Chapter 13: How Git Works
Related appendices: Appendix E: Advanced Git | Appendix D: Git Authentication
Authoritative Sources
Use these official references when you need the current source of truth for facts in this chapter.
- GitHub Docs, home
- GitHub Changelog
- About Git
- GitHub flow
- About pull requests
- About issues
- Contributing to a project
Section-Level Source Map
Use this map to verify facts for each major section in this file.
- Managing Repositories, Branches, and Changes Accessibly: GitHub Docs, home, GitHub Changelog, About Git, GitHub flow, About pull requests
- Workshop Recommendation (Chapter 14 / Challenge 10): GitHub Docs, home, GitHub Changelog, About Git, GitHub flow, About pull requests
- 1. Cloning a Repository in VS Code: GitHub Docs, home, GitHub Changelog, About Git, GitHub flow, About pull requests
- 2. The Source Control Panel - Complete Walkthrough: GitHub Docs, home, GitHub Changelog, About Git, GitHub flow, About pull requests
- 3. Branch Management: GitHub Docs, home, GitHub Changelog, About Git, GitHub flow, About pull requests
- 4. Staging Changes - Files, Lines, and Chunks: GitHub Docs, home, GitHub Changelog, About Git, GitHub flow, About pull requests
- 5. Committing with Screen Readers: GitHub Docs, home, GitHub Changelog, About Git, GitHub flow, About pull requests
- 6. Push and Pull Operations: GitHub Docs, home, GitHub Changelog, About Git, GitHub flow, About pull requests
- What to do if push fails: GitHub Docs, home, GitHub Changelog, About Git, GitHub flow, About pull requests
- Syncing Your Fork with the Upstream Repository: GitHub Docs, home, GitHub Changelog, About Git, GitHub flow, About pull requests
- Via VS Code Command Palette: GitHub Docs, home, GitHub Changelog, About Git, GitHub flow, About pull requests
- 7. Discarding Changes: GitHub Docs, home, GitHub Changelog, About Git, GitHub flow, About pull requests
- 8. Timeline View - File History and Blame: GitHub Docs, home, GitHub Changelog, About Git, GitHub flow, About pull requests
- 9. Resolving Merge Conflicts in VS Code: GitHub Docs, home, GitHub Changelog, About Git, GitHub flow, About pull requests
- Timeline View - File History: GitHub Docs, home, GitHub Changelog, About Git, GitHub flow, About pull requests
- Timeline View - Git History and Blame: GitHub Docs, home, GitHub Changelog, About Git, GitHub flow, About pull requests