All Articles

Git Commands Cheat Sheet - Every Command You Need (2026)

Published: March 15, 2026 · Updated: April 1, 2026

Git is the version control system used by virtually every software team on the planet. Mastering Git commands is not optional for developers — it is a fundamental skill. This guide covers every command from basic commits to advanced rebasing.

Daily Workflow Commands

Your daily Git cycle is: git pull (get latest) → make changes → git add . (stage) → git commit -m "message" (commit) → git push (share). These five commands handle 80% of your Git usage.

Branching Strategy

git checkout -b feature/new-login creates and switches to a new branch in one command. When done, merge with git checkout main && git merge feature/new-login. Delete the branch with git branch -d feature/new-login.

Undoing Mistakes

Committed too early? git reset --soft HEAD~1 undoes the commit but keeps changes staged. Need to completely revert? git reset --hard HEAD~1 removes the commit and all changes. For published commits, use git revert HEAD to create a new commit that undoes the previous one.

Stashing Work in Progress

Need to switch branches but have uncommitted changes? git stash saves them temporarily. Switch branches, do your work, switch back, and git stash pop restores everything. Use git stash list to see all stashed changes.

Advanced: Interactive Rebase

git rebase -i HEAD~5 lets you rewrite the last 5 commits — squash, reorder, edit messages, or drop commits entirely. Essential for cleaning up commit history before merging to main.

Search shortcuts for 230 platforms interactively

Open Shortcut Finder