Git provides several ways to undo changes: checkout, reset, and revert.
1. Getting Started
What is Git?
2. Branching & Merging
Branches & Merging
5. Tags & Releases
Git Tags
9. Submodules & Subtree
Git Submodules
10. GitHub Actions
GitHub Actions CI/CD
11. Git Worktrees
Git Worktrees
12. Git LFS
Git LFS (Large Files)
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.
Choose an answer to continue.
Interview Questions
It is a fundamental Git feature.