9 Git Commands Every Developer Should Know
Learn nine practical Git commands for saving work, undoing commits, inspecting changes, tracing bugs, and recovering lost history.
0 of 9 steps complete
Work faster without being careless
Basic Git commands are enough until a branch becomes messy, a commit lands in the wrong place, or you need to find exactly where a bug entered the codebase. This guide explains nine commands that solve those real development problems.
Each section includes the command, the safest use case, and the detail that prevents a useful command from becoming a destructive one. Try the read-only commands first, and practice reset operations in a test repository before using them on important work.
The screenshots are included as quick visual references. The code blocks remain the source you can copy into your terminal.
Temporarily save work with git stash
Use git stash when you need a clean working tree but are not ready to commit your changes.
git stash
git switch another-branch
git switch -
git stash pop
git stash pop restores the latest stash and removes it from the stash list. Use git stash apply instead when you want to restore the changes but keep the saved copy. Before switching branches, run git status so you understand exactly what is being stored.

Stash only selected changes with git stash -p
Undo the last commit but keep changes staged
Match a local branch to origin/main
Bring one commit across with git cherry-pick
Inspect the latest commit and its patch
Trace a line with git blame
Get the exact current commit ID
Recover lost commits with git reflog
Related AI setup guides
Install Claude Code Using OpenRouter (Free)
Get Claude Code running for free in minutes using OpenRouter's generous free-tier models. No Anthropic account needed.
Development ToolsSetup Continue.dev AI Autocomplete in VS Code
Add AI autocomplete, inline editing, and chat to VS Code using free local or API models.
AI Coding AssistantsInstall OpenAI Codex CLI
Run OpenAI's Codex CLI from your terminal to automate coding tasks, write scripts, and modify files with AI.
Development Tools7 Two-Color UI Combinations for Developer Projects
Seven ready-to-use two-color palettes with hex codes, contrast guidance, and practical UI roles for dashboards, apps, and landing pages.