Search and filter 60+ Git commands by category. Click any card to copy the command to your clipboard instantly.
Showing 83 of 83 commands — click any card to copy
Frequently Asked Questions
What is the difference between git fetch and git pull?
git fetch downloads changes from the remote repository into your local tracking branches but does not merge them into your working branch. git pull is essentially git fetch followed by git merge (or git rebase if configured) — it downloads the changes and immediately integrates them into your current branch. Use fetch when you want to inspect remote changes before merging.
What does git rebase do, and how is it different from git merge?
git merge creates a new merge commit that ties together the histories of two branches, preserving the full context of when each branch diverged. git rebase rewrites your branch's commits on top of another branch, producing a linear history without a merge commit. Rebase is useful for a cleaner commit history, but should be avoided on shared public branches because it rewrites commit SHAs.
How do I undo the last commit without losing my changes?
Run git reset HEAD~1. This moves the HEAD pointer back one commit and unstages those changes, leaving all your modified files intact in your working directory. If you also want to unstage them automatically, use git reset --soft HEAD~1. To discard the changes entirely (irreversibly), use git reset --hard HEAD~1.
What is git stash and when should I use it?
git stash temporarily shelves (stashes) changes you have made to your working directory so you can switch context — for example, to fix a bug on another branch — without committing unfinished work. Your changes are saved onto a stack and can be reapplied later with git stash pop (applies and removes the stash) or git stash apply (applies but keeps it in the stash list).