100% free AI setup guides — no credit card needed
Development ToolsIntermediate

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.

24 min9 steps22 viewsUpdated Aug 1, 2026
Your Progress0%

0 of 9 steps complete

gitgithubdeveloper-toolsversion-controlterminal

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

1 screenshot

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.

💡 Tip
Give important stashes a name with: git stash push -m "short description".
Screenshots
Visual guide explaining git stash and git stash pop
The basic git stash workflow.

Stash only selected changes with git stash -p

1 screenshot

Undo the last commit but keep changes staged

1 screenshot

Match a local branch to origin/main

1 screenshot

Bring one commit across with git cherry-pick

1 screenshot

Inspect the latest commit and its patch

1 screenshot

Trace a line with git blame

1 screenshot

Get the exact current commit ID

1 screenshot

Recover lost commits with git reflog

Related AI setup guides

Community Feedback

Did this guide work for you?

0/1000
Be the first to leave feedback!