Essential Git Commands, Branching & Advanced Workflows
Developer reference for daily Git commands, branch management, cherry-picking, interactive rebasing, undoing commits, and stash tricks.
Need to generate a .gitignore for your tech stack?
Create tailored .gitignore files for Node, Python, Rust, Go, macOS, Windows, and IDE configs.
Staging, Commits & Status
Everyday commands for tracking and committing changes.
| Syntax / Token | Name / Type | Description | Example / Notes |
|---|---|---|---|
git status | Status Overview | Shows modified, staged, and untracked files in working tree | — |
git add . | Stage All Changes | Stages all modifications and new files for next commit | — |
git add -p | Interactive Patch Staging | Interactively review and stage individual chunks/lines of code | — |
git commit -m "feat: description" | Commit Staged | Records staged snapshot to repository history with message | — |
git commit --amend --no-edit | Amend Previous Commit | Adds staged changes into the most recent commit without modifying commit message | — |
Branching & Merging
Creating, switching, and merging branches.
| Syntax / Token | Name / Type | Description | Example / Notes |
|---|---|---|---|
git checkout -b <branch-name> | Create & Switch Branch | Creates a new branch from current HEAD and checks it out | — |
git switch <branch-name> | Switch Branch (Modern) | Switches working directory to existing branch | — |
git merge <branch-name> | Merge Branch | Merges specified branch into current active branch | — |
git rebase main | Rebase onto Main | Replays current branch commits on top of latest main branch | — |
git cherry-pick <commit-hash> | Cherry-Pick Commit | Applies the changes from a specific commit into current branch | — |
Undoing Changes & Recovery
Safely undoing mistakes and recovering lost commits.
| Syntax / Token | Name / Type | Description | Example / Notes |
|---|---|---|---|
git reset --soft HEAD~1 | Undo Commit (Keep Staged) | Undoes the last commit but leaves changes staged ready to re-commit | — |
git reset --hard HEAD~1 | Discard Last Commit | Permanently discards last commit and all associated working changes | — |
git restore <file> | Discard Working File Changes | Discards uncommitted changes in a specific file | — |
git revert <commit-hash> | Revert Commit (Safe) | Creates a new inverse commit that safely undoes an older public commit | — |
git reflog | Reference Log | Shows log of all HEAD movements to recover accidentally deleted commits or branches | — |
Frequently Asked Questions
Common questions and developer tips regarding essential git commands & workflows reference.
Explore More Cheat Sheets
All Cheat Sheets →Regular Expression (RegEx) Syntax & Tokens
A complete developer cheat sheet for RegEx tokens, character classes, anchors, lookaheads, lookbehinds, flags, and common production patterns with 1-click copy.
Crontab Syntax & Schedule Reference
Quick reference guide for Unix/Linux crontab schedule syntax, 5-field time breakdown, step values, special characters, and common cron presets.
HTTP Status Codes (1xx–5xx) Quick Reference
Comprehensive quick reference for all standard RFC HTTP status codes, REST API conventions, caching behaviors, and client/server error definitions.