Quick answer

Use VS Code’s source-control panel to inspect changes, create a branch, commit and sync without losing work. Visual Studio Code offers built-in Git controls for everyday development. This guide walks through a safe example with a local README, so you can see what is committed and what remains on your computer before sharing changes.

Visual Studio Code offers built-in Git controls for everyday development. This guide walks through a safe example with a local README, so you can see what is committed and what remains on your computer before sharing changes.

Before you begin

Install VS Code and Git, set Git author name/email and open a non-sensitive practice repository. Save a backup before changing a valuable existing project.

Method guide · not a product benchmark

01Open and inspect the repository

Use File → Open Folder to open the repository directory. The Source Control view shows Git-tracked changes and the current branch. If it reports Git is unavailable, verify Git is installed and restart VS Code before editing anything important.

02Create a safe working branch

Use the branch name in the status bar or Source Control menu to create docs/first-edit from main. Confirm the new branch is selected before modifying files. A branch isolates work; it is not a backup of uncommitted files.

03Edit and review the diff

Open README.md, add one sentence and save. Click its change in Source Control to inspect the side-by-side diff. Check that unrelated files, generated assets, passwords, .env files or private datasets are not part of the change.

04Stage and commit deliberately

Stage only README.md using the plus control and review Staged Changes. Enter a specific commit message such as docs: clarify setup and commit. A commit records changes locally; it does not upload them to GitHub or automatically make them live.

05Push, pull and resolve conflicts

When your branch is ready, use Publish Branch or Push. Pull or Sync may incorporate remote changes, so inspect incoming work first. If a conflict appears, compare both versions using the merge editor, resolve it carefully, rerun your project checks and only then finish syncing.

Try this prompt

Check this VS Code Git change plan for accidental secrets, wrong branch, missing backup and missing tests. Do not claim any actions were executed: [plan].

Worked example

Fictional teaching example — not a product test or a real customer record.

Starting information

A fictional documentation change on a practice repository. No real commit or deployment has been performed.

Expected result

Expected outcome: a separate branch, one reviewed documentation commit and a proposed pull request.

Before you use the result

  • Verify current branch and repository visibility.
  • Check the diff for secrets and unrelated files.
  • Confirm actual changes and permissions before merging.

Worksheet

Editable text file. Fill it with your own evidence; blank fields are not results.

Download the worksheet (.txt)

Further reading

Back to the library