ToolSnippet
🌿Developer Cheat Sheet

Essential Git Commands, Branching & Advanced Workflows

Developer reference for daily Git commands, branch management, cherry-picking, interactive rebasing, undoing commits, and stash tricks.

1-Click Syntax CopyProduction-Tested StandardsInteractive Tool Companion
⚡

Need to generate a .gitignore for your tech stack?

Create tailored .gitignore files for Node, Python, Rust, Go, macOS, Windows, and IDE configs.

Launch .gitignore Multi-Ecosystem Generator →

Staging, Commits & Status

Everyday commands for tracking and committing changes.

Syntax / TokenName / TypeDescriptionExample / Notes
git status
Status OverviewShows modified, staged, and untracked files in working tree—
git add .
Stage All ChangesStages all modifications and new files for next commit—
git add -p
Interactive Patch StagingInteractively review and stage individual chunks/lines of code—
git commit -m "feat: description"
Commit StagedRecords staged snapshot to repository history with message—
git commit --amend --no-edit
Amend Previous CommitAdds staged changes into the most recent commit without modifying commit message—

Branching & Merging

Creating, switching, and merging branches.

Syntax / TokenName / TypeDescriptionExample / Notes
git checkout -b <branch-name>
Create & Switch BranchCreates 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 BranchMerges specified branch into current active branch—
git rebase main
Rebase onto MainReplays current branch commits on top of latest main branch—
git cherry-pick <commit-hash>
Cherry-Pick CommitApplies the changes from a specific commit into current branch—

Undoing Changes & Recovery

Safely undoing mistakes and recovering lost commits.

Syntax / TokenName / TypeDescriptionExample / 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 CommitPermanently discards last commit and all associated working changes—
git restore <file>
Discard Working File ChangesDiscards 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 LogShows 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 →