The Source Control panel
Look at the left sidebar in VS Code. The icon that looks like a branching diagram is the Source Control panel. Click it to open it. When you’re inside a Git repository, the Source Control panel shows:- All files you’ve changed since your last commit, listed under “Changes”
- A text box at the top for writing your commit message
- A checkmark button to save your commit
- A
...menu for less common operations like pulling and pushing
Basic commit workflow
1. See what you’ve changed
Open the Source Control panel. Every file you’ve modified since your last commit appears in the Changes list. Click any file to open a side-by-side diff view:- Green lines — text you added
- Red lines — text you removed
2. Stage your changes
Before committing, you choose which changes to include — this is called “staging”:- Hover over any file in the Changes list and click the + icon to stage that file
- Click the + next to the “Changes” heading to stage everything at once
3. Write a commit message and commit
With your files staged:- Click in the message box at the top of the panel
- Type a short, descriptive message like
Add sales analysis function - Press
Ctrl+Enteron Windows/Linux orCmd+Enteron Mac (or click the ✓ checkmark button)
4. Push to GitHub
After committing, upload your changes:- Click the … menu in the Source Control panel, then click Push
- Or click the sync icon in the bottom status bar — it shows arrows indicating pending pushes and pulls
Visual change indicators
VS Code marks changed files in multiple places:- Explorer panel — Modified files show a coloured letter (M for modified, U for untracked)
- Editor gutter — A coloured bar on the left side of the editor shows exactly which lines changed
- Blue bar — Line was modified
- Green bar — Line was added
- Red triangle — Lines were 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 the Initialize Repository button
- Git is now tracking your project — all your files appear as new changes ready to stage
Clone a repository from GitHub
Clone a repository from GitHub
- Press
Ctrl/Cmd + Shift + Pto open the Command Palette - Type Git: Clone and press Enter
- Paste the GitHub repository URL
- Choose where to save the project on your computer
- VS Code downloads the project and opens it automatically
Create a .gitignore file
Create a .gitignore file
- Create a new file in your project root called
.gitignore - Add these essential Python patterns:
.gitignore based on your project language.Discard changes to a file
Discard changes to a file
Made a mistake and want to go back to the last committed version?
- Open the Source Control panel
- Right-click the file you want to revert
- Select Discard Changes
- VS Code asks you to confirm before reverting — click Discard Changes again
The sync button in the status bar
The status bar at the very bottom of VS Code shows a sync button with arrows. The numbers next to the arrows tell you the state of your repository:- ↓ 3 — There are 3 commits on GitHub that you haven’t downloaded yet (you need to pull)
- ↑ 2 — You have 2 local commits that haven’t been pushed to GitHub yet
- Click the button to sync in both directions at once
Tips for building good habits
- Commit often — A commit after every small feature or bug fix is better than one massive commit at the end of the day
- Write clear messages —
Fix login form validation bugis infinitely more useful thanchangesorstuff - Pull before you start — If you work on multiple machines, always pull the latest changes before writing new code
- Check your .gitignore — Before your first push, verify that secrets and large folders won’t be uploaded
Terminal vs VS Code UI — quick reference
Both approaches do exactly the same thing. Use whichever feels most comfortable:What’s next?
You now have all the Git skills you need for daily development. Next, learn how to keep your API keys and other secrets safe using environment variables.Environment & Secrets
Store your API keys safely outside of your code