As developers, we often find ourselves looking up the same commands and syntax repeatedly. Having quick reference guides—cheatsheets—can significantly boost productivity and reduce context switching. This comprehensive guide covers essential cheatsheets for Git, JavaScript, React, CSS, and other tools that every developer should have bookmarked.
Why Cheatsheets Matter
Cheatsheets serve as quick reference guides that help you work faster without interrupting your flow. Instead of searching through documentation or Stack Overflow, a well-organized cheatsheet gives you instant access to the information you need. They're especially valuable for commands and patterns you use regularly but don't memorize.
Git Cheatsheet: Essential Version Control Commands
Git is the foundation of modern version control. Mastering these commands will make your development workflow much smoother.
Basic Git Commands
These are the commands you'll use daily:
git status- Check repository status and see which files have changedgit add .- Stage all changes in the current directorygit add <file>- Stage a specific filegit commit -m "message"- Commit changes with a messagegit commit -am "message"- Stage and commit all tracked filesgit push origin main- Push commits to remote repositorygit pull- Pull latest changes from remotegit fetch- Download changes without merging
Branch Management
Branches are essential for organizing your work:
git branch- List all local branchesgit branch -a- List all branches (local and remote)git checkout -b feature-name- Create and switch to a new branchgit checkout branch-name- Switch to an existing branchgit branch -d branch-name- Delete a local branchgit merge branch-name- Merge a branch into the current branch
Advanced Git Commands
For more complex scenarios:
git stash- Temporarily save uncommitted changesgit stash pop- Apply stashed changesgit log- View commit historygit log --oneline- Compact commit historygit diff- See changes between commitsgit reset --soft HEAD~1- Undo last commit, keep changes stagedgit revert HEAD- Create a new commit that undoes changes
JavaScript Essentials: Modern Syntax and Patterns
JavaScript has evolved significantly. Here are the modern patterns and syntax you should know.
Array Methods
These methods are essential for data manipulation:
map()- Transform each element:arr.map(x => x * 2)filter()- Select elements:arr.filter(x => x > 0)reduce()- Accumulate values:arr.reduce((acc, x) => acc + x, 0)forEach()- Execute function for each elementfind()- Find first matching elementsome()- Check if any element matches conditionevery()- Check if all elements match conditionincludes()- Check if array contains value
Object and Array Destructuring
Destructuring makes code cleaner and more readable:
const { prop, other } = obj- Object destructuringconst [first, second] = array- Array destructuringconst { prop: alias } = obj- Destructuring with renamingconst { prop = defaultValue } = obj- Destructuring with default values
Spread and Rest Operators
Powerful operators for working with arrays and objects:
[...array]- Spread array elements{...obj}- Spread object properties[...array1, ...array2]- Combine arrays{...obj1, ...obj2}- Merge objectsfunction(...args)- Rest parameters
Template Literals
Modern string interpolation:
`Hello ${name}`- Basic interpolation`Multi-line string`- Multi-line strings`Value: ${value.toFixed(2)}`- Expression evaluation
Arrow Functions
Concise function syntax:
const fn = () => {}- Basic arrow functionconst fn = x => x * 2- Single parameter, implicit returnconst fn = (x, y) => x + y- Multiple parameters
Async/Await
Modern asynchronous programming:
async function fn() {}- Async function declarationconst result = await promise- Await promise resolutiontry/catch- Error handling with async/await
React Quick Reference: Components and Hooks
React's component model and hooks are fundamental to modern React development.
Component Structure
Basic functional component pattern:
function Component(props) { return JSX }- Function componentconst Component = (props) => JSX- Arrow function componentexport default Component- Default exportexport { Component }- Named export
Essential React Hooks
Hooks are the foundation of modern React:
useState(initialValue)- State managementuseEffect(() => {}, [deps])- Side effects and lifecycleuseContext(Context)- Access React ContextuseRef(initialValue)- Mutable referenceuseMemo(() => value, [deps])- Memoize expensive calculationsuseCallback(() => {}, [deps])- Memoize functionsuseReducer(reducer, initialState)- Complex state logic
Common React Patterns
Patterns you'll use frequently:
props.children- Access child elementskey={id}- List item keysonClick={handleClick}- Event handlersclassName="..."- CSS classes (not class)style={{ prop: value }}- Inline styles
CSS Flexbox & Grid: Modern Layout Systems
Flexbox and Grid are powerful tools for creating responsive layouts.
Flexbox Properties
Flexbox is perfect for one-dimensional layouts:
display: flex- Enable flexboxflex-direction: row | column- Main axis directionjustify-content: center | space-between | space-around- Main axis alignmentalign-items: center | stretch | flex-start- Cross axis alignmentflex-wrap: wrap- Allow items to wrapgap: 1rem- Space between itemsflex: 1- Grow to fill available space
CSS Grid Properties
Grid excels at two-dimensional layouts:
display: grid- Enable gridgrid-template-columns: repeat(3, 1fr)- Define columnsgrid-template-rows: auto- Define rowsgrid-gap: 1rem- Gap between grid itemsgrid-column: span 2- Span multiple columnsgrid-row: span 2- Span multiple rowsgrid-area: name- Named grid area
TypeScript Quick Reference
TypeScript adds type safety to JavaScript:
const x: string = "hello"- Type annotationinterface User { name: string }- Interface definitiontype Status = 'active' | 'inactive'- Union typesconst fn = (x: number): number => x * 2- Function typesconst arr: number[] = [1, 2, 3]- Array typesconst obj: { prop: string } = { prop: "value" }- Object types
npm/yarn Commands
Package management essentials:
npm install package- Install packagenpm install -D package- Install dev dependencynpm uninstall package- Remove packagenpm run script- Run npm scriptnpm update- Update packagesyarn add package- Yarn installyarn remove package- Yarn uninstall
Creating Your Own Cheatsheet
While this guide covers common patterns, consider creating your own personalized cheatsheet:
- Document commands you use frequently
- Include project-specific patterns
- Add notes and examples
- Keep it updated as you learn new things
- Share it with your team
Conclusion
Cheatsheets are invaluable tools that save time and improve productivity. Keep this reference handy, bookmark it, and consider creating your own personalized version with commands and patterns specific to your workflow. The goal isn't to memorize everything, but to have quick access to the information you need when you need it.