Git Workflows Best Practices
4 min read Quiz at the end
Best practices: small commits, Conventional Commits format, PR reviews, protected main branch.
Git Best Practices
- Commit early, commit often — small focused commits are easier to review and revert
- Write descriptive commit messages — use Conventional Commits: feat:, fix:, docs:, chore:
- Never force push to shared branches — use --force-with-lease if you must
- Keep main deployable always — use feature flags for incomplete features
- Review before merge — all code through PR with at least one review
- Delete merged branches — keeps repo clean
- Use .gitignore — never commit secrets, build artifacts, or IDE files
- Sign commits — use GPG signing for verified commits on GitHub
# Conventional Commits
git commit -m "feat(auth): add OAuth2 login"
git commit -m "fix(api): handle null user response"
git commit -m "docs: update README with Docker setup"
Topic Quiz · 1 questions
Test your understanding before moving on
1. What does git push --force-with-lease do?
💡 --force-with-lease prevents overwriting remote commits you have not seen yet.