View a List of Commits & Undo Changes
Master Git Version Control in Visual Studio Code
Understanding how to view and undo changes is essential for maintaining clean code history and recovering from mistakes in your development workflow.
Discard Uncommitted Changes
Open Source Control Panel
Navigate to the Source Control panel where you can see all modified files that haven't been committed yet.
Hover Over Changed Files
Find files containing unwanted changes and hover over them to reveal the action buttons.
Discard Changes
Click the Discard Changes button and confirm to revert the file to its previous committed state.
Git Graph Extension Benefits
Visual Commit History
View your Git history in an intuitive graphical interface that makes understanding your project timeline easier.
Enhanced File Tracking
Click on commits to see exactly which files were changed and review the specific modifications made.
Advanced Git Operations
Access powerful Git commands like drop and revert directly from the visual interface with right-click context menus.
Git Graph Access Methods
| Feature | Blue Bar Method | Source Control Method |
|---|---|---|
| Location | Bottom left blue bar | Top of Source Control panel |
| Button Name | Git Graph | View Git Graph |
| Convenience | Always visible | Context-specific |
Undoing your last unpushed commit keeps your Git history cleaner by allowing you to fix mistakes before they become part of the permanent record.
After Undoing Last Commit
Your changes remain staged, allowing you to unstage specific files if needed
Include any files you originally forgot in the previous commit
Edit files further before creating your corrected commit
Make a proper commit with all necessary changes included
Drop Unpushed Commits
Analyze Commit History
Review commit messages and examine file changes to identify which commits should be removed from your history.
Right-Click Target Commit
Use CTRL-click on Mac or Right-click on Windows to access the context menu for the commit you want to drop.
Confirm Deletion
Select Drop from the menu and confirm the action to completely remove the commit and reverse its changes.
Git Graph vs GitLens Extensions
| Feature | Git Graph | GitLens |
|---|---|---|
| Primary Focus | Visual commit history | Comprehensive Git integration |
| UI Additions | Git Graph tab | Multiple panels and buttons |
| Code Annotations | Limited | Inline blame information |
| Learning Curve | Simple | More complex |
GitLens Advanced Features
Enhanced Source Control Sections
Adds dedicated panels for Commits, File History, Branches, and other Git operations directly in Source Control.
Navigation Controls
Provides additional Git buttons in the top-right window area for quick navigation between changes and commits.
Inline Code Attribution
Shows author, date, and commit information directly in your code editor for every line you're currently viewing.
Key Takeaways