🔀 Git Commands Cheat Sheet

Complete Git reference — from basic setup to advanced workflows. Commands, options, and real-world examples.

📖 Common Git Workflows

# Start a new feature
git checkout -b feature/new-feature
# Work on your code, then stage and commit
git add .
git commit -m "feat: add new feature"
# Push to remote and create PR
git push -u origin feature/new-feature
# After PR is merged, clean up
git checkout main
git pull origin main
git branch -d feature/new-feature
# Undo last commit (keep changes)
git reset --soft HEAD~1
# Undo last commit (discard changes)
git reset --hard HEAD~1
# Amend last commit message
git commit --amend -m "new message"

❓ Frequently Asked Questions

git merge creates a new merge commit that combines two branches. It preserves full history but can create a cluttered log. git rebase replays your commits on top of another branch, creating a linear history. Use merge for public/shared branches and rebase for local feature branches before merging.

Use git revert <commit-hash> to create a new commit that undoes the changes (safe for shared branches). Avoid git reset --hard + force push on shared branches as it rewrites history and can break other developers' work.

📖 What Are Git Commands?

Git is the world's most popular version control system, used by over 90% of software developers. It tracks changes to code, enables collaboration, and maintains complete project history. Understanding Git commands is essential for software development, DevOps, and any collaborative technical work.

Our interactive cheat sheet covers essential commands from basic (init, add, commit) to advanced (rebase, cherry-pick, reflog) with practical examples and workflow guides.

🚀 How to Use This Tool

  1. Select a command category (Setup, Basic, Branching, Remote, etc.)
  2. Browse commands with descriptions and examples
  3. Use the search bar to find specific commands
  4. Follow the workflow guides for common Git scenarios

💡 Tips & Best Practices

Best Practice: Write clear commit messages: "feat: add user login" not "updated stuff." Use feature branches for all changes. Pull before pushing to avoid conflicts. Never force-push to shared branches.

🔗 Related Tools