Stage & Commit Files
Master Git's essential workflow for version control
Git tracks all changes to your files but requires you to explicitly tell it which changes to record. This two-step process of staging and committing gives you precise control over your project history.
Core Git Concepts
Working Directory
Your local files where you make changes. Git monitors this area for modifications, additions, and deletions.
Staging Area
A temporary holding area for changes you want to include in your next commit. Gives you control over what gets recorded.
Repository
The permanent record of your project history. Each commit creates a snapshot that you can return to later.
Opening Your Project in VS Code
Access File Menu
Navigate to File > Open (Mac) or File > Open Folder (Windows) from the top menu bar
Select Project Directory
Browse to your Git repository folder and select it from the file system dialog
Open Source Control
Click the Source Control panel icon on the left sidebar to view your Git status
Git File Status Indicators
M - Modified
Files that have been changed since the last commit. These files exist in Git's history but contain new modifications.
U - Untracked
New files that Git has never seen before. These files need to be added to Git's tracking system.
D - Deleted
Files that have been removed from your working directory. Git needs to record these deletions in its history.
Staging allows you to commit only the files that are ready, even when you're working on multiple files simultaneously. This granular control helps create clean, focused commits.
Staging Operations in VS Code
Stage All Changes
Hover over 'Changes' section and click the plus (+) button to stage all modified files at once
Stage Individual Files
Hover over specific file names and click their individual plus (+) buttons for selective staging
Unstage Files
Use the minus (-) button next to staged files to remove them from the staging area if needed
Write commit messages in imperative mood like 'Make headings blue' rather than past tense like 'Made headings blue'. This communicates what your code will do when applied.
Commit Message Style Guide
| Feature | Poor Examples | Good Examples |
|---|---|---|
| Tense Usage | I made headings blue | Make headings blue |
| Specificity | Fixed stuff | Fix navigation menu overflow |
| Length | Updated the entire user interface styling and layout across multiple components | Update user interface styling |
Pre-Commit Checklist
Ensure only intended files are included in the commit
Describe what the commit will do, not what you did
Check the colored bars next to line numbers for modified lines
Complete the commit process to record changes permanently
Key Takeaways
