When working with Git, git checkout and git reset are two of the most powerful—and dangerous—commands in version control. Both move you through Git history, but they work in very different ways. Knowing the difference changes how you think about fixing mistakes, switching work, and cleaning history.
What git checkout doesgit checkout lets you move between branches, tags, or commits without rewriting history. It changes what’s in your working directory and updates HEAD to point to a new branch or commit. This is ideal when you want to:
- Switch to another branch
- Inspect an older commit without changing history
- Create a new branch from a specific point
Example:
git checkout feature/login
git checkout 1a2b3c4
After this, your working directory matches that branch or commit. No commits are removed.
What git reset doesgit reset shifts the current branch’s HEAD to a specific commit. It can also change the staging area and the working directory depending on the mode used: