Git Basics Quick Reference Cheat Sheet
Key Takeaways
- โKeep this Git Basics reference bookmarked for quick daily lookups
- โFocus on memorizing the essential commands first before advancing
- โCombine commands with pipes and redirection for powerful workflows
- โUse tab completion and aliases to speed up common operations
Repository Setup Commands
git init # Create new repo
git clone <url> # Clone existing repo
git clone --depth 1 <url> # Shallow clone
git config --global user.name "" # Set name
git config --global user.email "" # Set email
git config --list # View all configStaging and Committing
git status # Show working tree status
git add <file> # Stage specific file
git add . # Stage all changes
git add -p # Stage interactively
git commit -m "message" # Commit staged changes
git commit --amend # Edit last commit
git reset HEAD <file> # Unstage a file
git restore <file> # Discard changesBranching Quick Reference
git branch # List local branches
git branch -a # List all branches
git branch <name> # Create branch
git checkout <name> # Switch branch
git switch <name> # Switch (modern)
git checkout -b <name> # Create + switch
git branch -d <name> # Delete branch
git branch -D <name> # Force deleteIs Your Codebase Production-Ready? Find Out Before Your Users Do.
Upload your repo. Get a full QA audit: bugs, security, performance, best practices.
Audit My ProjectRemote Operations
git remote -v # List remotes
git remote add origin <url> # Add remote
git push -u origin <branch> # Push + track
git pull origin <branch> # Pull changes
git fetch --all # Fetch all remotes
git push --tags # Push all tags
git remote prune origin # Clean stale refsInspection and History
git log --oneline # Compact log
git log --graph --all # Visual branch graph
git log -p <file> # File change history
git diff # Unstaged changes
git diff --staged # Staged changes
git blame <file> # Line-by-line author
git show <commit> # Show commit details
git shortlog -sn # Contributor statsUndo and Recovery
git checkout -- <file> # Discard file changes
git reset --soft HEAD~1 # Undo commit, keep staged
git reset --mixed HEAD~1 # Undo commit + unstage
git reset --hard HEAD~1 # Undo commit + discard
git revert <commit> # Reverse a commit safely
git stash # Temporarily shelve
git stash pop # Restore shelved
git reflog # Recovery safety netUnlock Unlimited QA Audits for $15.99/mo
Free: 5 audits/day. Pro $15.99/mo: 50/day + 250 pages. Pro Max $99/mo: unlimited audits, 10K pages, API access.
See PlansFrequently Asked Questions
How should I use this Git Basics cheat sheet?
Bookmark this page and reference it when you need exact syntax for Git Basics commands. Focus on memorizing the commands in the essentials section first, as you will use those daily. As specific situations arise, consult the advanced sections. Over time, the most-used commands will become muscle memory.
What are the most important Git Basics commands to memorize?
Start with the five to ten commands you use most frequently in your daily workflow. For most developers, these include the basic operations covered in the first section of this cheat sheet. Once those are automatic, gradually add intermediate commands. Do not try to memorize everything at once โ learn commands as you need them.
Does this cheat sheet cover the latest Git Basics version?
Yes, this cheat sheet is updated for 2026 and covers the latest stable version. We verify all commands against current releases and update the page when significant changes occur. If you encounter a command that does not work, check your installed version and update if necessary.
Can I print this Git Basics cheat sheet?
Yes, this page is designed to be print-friendly. Use your browser's print function and select the content area. Consider printing just the sections most relevant to your current work and keeping them near your workspace as a quick reference until the commands become second nature.
Where can I practice these Git Basics commands?
Set up a test environment where you can experiment safely without affecting real projects. For command-line tools, create a practice directory with sample files. For Docker, use throwaway containers. For Git, create a test repository. Practice in a safe environment builds confidence and muscle memory without risk.
Related Articles
Unlock Unlimited QA Audits for $15.99/mo
Free: 5 audits/day. Pro $15.99/mo: 50/day + 250 pages. Pro Max $99/mo: unlimited audits, 10K pages, API access.
See PlansBliniBot is an AI assistant that automates repetitive browser tasks and workflows. Try it free โ
Is your site built to last?
Run a free QA audit and get your Site Health Score in seconds.
Check Your Site FreeNo signup required