The Source Control panel
Open the Source Control panel from the left sidebar — it’s the icon that looks like a branching diagram. You can also pressCtrl + Shift + G (Windows/Linux) or Cmd + Shift + G (macOS).
Inside the panel you’ll see:
- Changes — every file you’ve modified since the last commit
- A message box at the top for your commit message
- A checkmark button to commit staged files
Basic workflow
1. See your changes
When you edit files, they appear automatically under Changes. Green highlighted lines are additions, red are deletions.2. Stage changes
Staging means telling Git which changes to include in the next commit.- Hover over a file name → click the + icon to stage that file
- Click the + next to the Changes heading to stage everything at once
3. Commit
1
Type your commit message
Click the message box at the top of the Source Control panel and type a clear description, for example:
Add weather data fetch function.2
Commit
Press
Ctrl / Cmd + Enter, or click the ✓ (checkmark) button. Your snapshot is saved locally.4. Push to GitHub
After committing, your changes exist only on your machine until you push:- Click the … menu in the Source Control panel → Push
- Or click the sync icon in the bottom-left status bar (it looks like a circular arrow)
Visual features
VS Code colour-codes the editor gutter to show file status at a glance:- Blue bar — lines modified since last commit
- Green bar — new lines added
- Red triangle — lines deleted
Common VS Code Git tasks
Initialize a new repository
Initialize a new repository
- Open your project folder in VS Code
- Open the Source Control panel
- Click Initialize Repository
Clone a repository
Clone a repository
- Press
Ctrl / Cmd + Shift + P - Type Git: Clone
- Paste the GitHub URL
- Choose where to save it
- VS Code opens the cloned project automatically
Create a .gitignore file
Create a .gitignore file
Create a new file named
.gitignore in your project root. A solid Python starting point:Discard changes
Discard changes
Made a mistake and want to revert a file to its last committed state?
- Open the Source Control panel
- Right-click the file
- Select Discard Changes
- Confirm the prompt
The sync button
The bottom-left status bar always shows your Git status. Look for something like ↓ 3 ↑ 2:- ↓ 3 means there are 3 remote commits to pull down
- ↑ 2 means you have 2 local commits ready to push
Terminal vs UI — a quick comparison
Both approaches are valid. Use whichever feels natural:Tips for a healthy Git habit
- Commit often — Small, frequent commits are easier to understand and revert than large ones
- Write clear messages —
"Fix login bug"is useful;"changes"is not - Pull before you start — Always get the latest changes before beginning a work session
- Guard your secrets — Double-check your
.gitignorebefore every commit
What’s next?
Now that you know Git, it’s time to learn how to keep your API keys and configuration values safe using environment variables.Environment & Secrets
Keep your API keys out of your code