Review before committing
Always review your changes before committing them to ensure code quality and prevent mistakes.
Use git diff
and git status
to review staged and unstaged changes before committing. This helps catch errors, debug statements, and unintended changes.
git add .
# Blindly added accidental changes
# to the next commit.
git commit -m "Fixed login bug"
git push
Committing without reviewing changes.
git add .
# Review changes before committing
git diff --staged
git commit -m "Fixed login bug"
git push
Review changes before the commit to prevent accidental changes pushed to the repository.
What can typically slip through without a review
Debugging leftovers, such as console.log statements, temporary variables/functions, etc.
Commented-out code, completed TODOs.
Changes unrelated to the next commit. Happens often when you work on several features simultaneously.
Temporary API keys or other secrets that should not be in the repository. These should rather be added to .gitignore
.
Overall code quality issues, such as syntax errors, typos, or formatting problems. Looking over the code before committing helps catch these because you can focus on the changes made rather than the entire file while reviewing the diff.
Useful review commands
See what files have changed:
git status
Review unstaged changes:
git diff
Review staged changes:
git diff --staged
Review changes in a specific file:
git diff src/auth.js
Show detailed changes with context:
git diff --word-diff
Review in VS Code GUI
Reviewing changes in the VS Code GUI is straightforward, and there's literally no excuse not to do it before a commit. Just open the Source Control panel, and you will see all the changes made in the current branch.

Oops, I forgot to remove a TODO comment for the change I've made.