Goal: Learn the fundamental Git workflow using VS Code's Source Control panel.
Scenario: You are starting a personal recipe book. Each recipe is a text file. No coding knowledge needed!
Open VS Code and use the terminal inside it (Terminal → New Terminal) for the few setup steps that require it. Everything else will use the Source Control panel (the icon that looks like a branch on the left sidebar, or press Ctrl+Shift+G / Cmd+Shift+G).
-
In the terminal, create and open a new folder:
mkdir recipe-book && cd recipe-book && code .
-
In VS Code, open the Source Control panel (
Ctrl+Shift+G). Click "Initialize Repository".VS Code runs
git initfor you — no command needed! -
The Source Control panel is now active. Notice it shows 0 changes — your repository is empty.
-
Create a new file: In the Explorer panel, click the New File icon and name it
pancakes.txt. -
Add this content and save (
Ctrl+S):Simple Pancakes ================ Ingredients: flour, eggs, milk, butter Mix everything together and cook on a hot pan. -
Switch to the Source Control panel. You'll see
pancakes.txtlisted under Changes with aUbadge (Untracked). -
Stage the file: Hover over
pancakes.txtand click the+(Stage Changes) icon next to it. The file moves to Staged Changes. -
Write a commit message: Click in the message box at the top of the Source Control panel and type:
Add pancakes recipe -
Commit: Click the ✓ Commit button (or press
Ctrl+Enter).The changes are now saved to Git history!
-
Open
pancakes.txtand add a new line at the end:Flip after 2 minutes. Serve with maple syrup.Save the file.
-
In the Source Control panel, click on
pancakes.txtunder Changes. VS Code opens a diff view — additions are shown in green, removals in red.This is the VS Code equivalent of
git diff. -
Stage the file (
+icon), write the messageAdd flipping instructions to pancakes, and commit.
-
Create
omelette.txtin the Explorer and add:Cheese Omelette ================ Ingredients: eggs, cheese, salt, pepper Beat eggs, pour into pan, add cheese, fold and serve. -
Stage and commit with the message
Add cheese omelette recipe.
Sometimes you have files you don't want Git to track (temp files, editor backups, etc.).
-
Create a file called
notes.tmpin the Explorer. Add any text to it and save. -
In the Source Control panel you'll see it listed as untracked. To tell Git to ignore it:
- Create a new file called
.gitignorein the Explorer. - Add this line and save:
*.tmp
- Create a new file called
-
Notice
notes.tmpdisappears from the Source Control panel — Git is now ignoring it. -
Stage
.gitignoreand commit with the messageAdd .gitignore to exclude temp files.
- What is the difference between an untracked file and a modified file in the Source Control panel?
- Why do we stage changes before committing, instead of committing directly?
- What happens if you close VS Code without committing — are your file edits lost?