Git Cheat Sheet
Common Git workflows with step-by-step commands.
Start New Feature
Create feature branch from latest main
Fix a Bug
Create bugfix branch
Merge Feature to Main
Merge completed feature
Undo Last Commit
Keep changes but remove commit
Sync Fork with Upstream
Update forked repository
Git Workflow Quick Reference
This cheat sheet provides common Git workflows with complete command sequences. Instead of remembering individual commands, follow these step-by-step guides for typical development tasks.
From starting new features to merging code and syncing forks, these workflows represent best practices used by development teams worldwide.
Feature Branch Workflow
Always create feature branches from an updated main branch. Name branches descriptively (feature/user-auth). Push branches for code review before merging. Delete branches after merging.
Commit Message Conventions
Use conventional commits: feat: for features, fix: for bugs, docs: for documentation. This enables automated changelog generation and semantic versioning.
Keeping Forks Updated
When contributing to open source, keep your fork synchronized with the upstream repository. Add upstream as a remote and merge regularly to avoid conflicts.