Git provides several ways to undo changes: checkout, reset, and revert.
Getting Started
What is Git?
Branching & Merging
Branches & Merging
Tags & Releases
Git Tags
Submodules & Subtree
Git Submodules
GitHub Actions
GitHub Actions CI/CD
Git Worktrees
Git Worktrees
Git LFS
Git LFS (Large Files)
Git
Beginner
FREE
Undoing Changes
Lesson 2 of 17
Beginner
Interactive
Syntax
GIT
git checkout -- file.txt git reset HEAD file.txt git reset --soft HEAD~1 git revert HEAD
Undoing Changes
BASH
# Undo working changes git checkout -- filename.txt git restore filename.txt # Unstage file git reset HEAD filename.txt # Amend last commit git commit --amend -m "Updated message" # Revert commit (creates new commit) git revert abc1234
Practice
1
Exercise
Practice this concept.
Answer
Run the commands as shown above.
Quick Quiz
1
What did you learn?
This covers the basics.
Interview Questions
It is a fundamental Git feature.