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 --stagedgit commit -m "Fixed login bug"git push
OR
# Stage only the intended file.git add src/login.js# Still, review before committing.git diff --stagedgit 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 statusReview unstaged changes:
git diffReview staged changes:
git diff --stagedReview changes in a specific file:
git diff src/auth.jsShow detailed changes with context:
git diff --word-diffReview in a VS Code-based editor
If you use VS Code, Cursor, Antigravity IDE, or another VS Code-based editor, reviewing uncommitted changes in the GUI is straightforward. Open the Source Control panel, and you'll see the files changed in your working tree.

Oops, I forgot to remove a TODO comment for the change I've made.
.gitignore filegit checkoutgit configgit taggit worktree