Best practices

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.

Bad
git add .
# Blindly added accidental changes
# to the next commit.
git commit -m "Fixed login bug"
git push

Committing without reviewing changes.

Good
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 made.

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

© 2024-2025 GitByBit.All rights reserved.

Hi! I'm Alex, creator of GitByBit.

And this is Gitopedia—a reference that summarizes knowledge in my Git course.

Gitopedia is designed to be a personal knowledge base. When you progress through the main Git course in VS Code, you unlock all of these topics, one by one, bit by bit. This gives you time to digest the information and gradually build the mental model of Git. Here's an example of how it works:

Learning directly in VS Code lets you practice Git exactly as you would in real life, doing real jobs, writing real code. In addition, the course has access to your actual terminal, so it can point out mistakes, suggest workarounds, etc.

The course is FREE, there are no Ads or other bullshit. There are optional premium add-ons you can purchase, mainly to support my work (regrettably, I have to eat every day), but that's totally up to you.

Learn Git in VS Code