Lesson 21 +15 XP

Git Workflow and Best Practices

Git Workflow and Best Practices

A good Git habit is to follow a simple, repeatable workflow and to follow best practices so your history stays clean and your team stays happy.

The basic workflow

The everyday loop is:

git status
git add .
git commit -m "Message"
git push

Check what changed, stage it, save it, then share it.

Best practices

  • Commit often, in small, logical pieces.
  • Write clear messages that describe the why, not just the what.
  • Pull before you push to grab other people's changes first.
  • Never commit secrets like passwords or API keys.
  • Use branches for new features, keep main stable.
  • Don't commit generated files or dependencies; use a .gitignore.

A good commit message

Bad: updated stuff

Good: Add password reset link to login page

A good message lets you read history like a story.

One feature, one commit

Group related changes into a single commit. This makes it easy to undo one feature without losing other work.

TL;DR

  • Workflow: status, add, commit, push.
  • Commit often and write clear messages.
  • Pull before pushing.
  • Never commit secrets or generated files.
  • Keep main stable and use branches for features.