cod-ai.com

Git Commands Cheat Sheet: The 20 Commands You Actually Need

Published 2026-03-16 · cod-ai.com

Git has hundreds of commands. You need about 20 for daily work. Here they are, organized by workflow.

Starting Work

git clone <url>          # Download a repo
git pull                   # Update local code
git checkout -b feature    # Create new branch
git status                 # See what changed

Making Changes

git add .                  # Stage all changes
git add file.js            # Stage specific file
git commit -m "message"    # Commit with message
git push                   # Upload to remote

Branch Management

git branch                 # List branches
git checkout main          # Switch branch
git merge feature          # Merge branch
git branch -d feature      # Delete branch

Fixing Mistakes

git stash                  # Save work temporarily
git stash pop              # Restore saved work
git reset --soft HEAD~1    # Undo last commit, keep changes
git checkout -- file.js    # Discard changes to file
git revert <hash>          # Undo a specific commit safely

Need AI Help?

Stuck on a complex git situation? Describe it to our AI Code Assistant and get the exact commands you need.

Try Our Free Tools

All tools mentioned in this article are 100% free.

Explore All Tools →