Commit Best Practices
Good Git habits make your project history useful for your entire team.
- Commit early and often — small, focused commits
- Write meaningful commit messages
- Don't commit generated files (use .gitignore)
- Don't commit secrets (API keys, passwords)
- Review your diff before committing: git diff --staged
- One logical change per commit
Collaboration Best Practices
When working with a team, these practices prevent common issues.
- Pull before you push to avoid conflicts
- Use feature branches — never commit directly to main
- Keep branches short-lived (1-3 days)
- Write descriptive PR descriptions
- Review others' code thoroughly and kindly
- Use conventional commit messages for automated changelogs
Useful Git Aliases
Set up aliases to speed up your Git workflow.
Example
# Add useful aliases
git config --global alias.s "status"
git config --global alias.co "checkout"
git config --global alias.br "branch"
git config --global alias.cm "commit -m"
git config --global alias.lg "log --oneline --graph --all"
git config --global alias.last "log -1 HEAD"
# Now use shortcuts:
git s # git status
git co main # git checkout main
git lg # pretty log graph 