Master the art of undoing mistakes in Git. Learn to restore files, unstage changes, undo commits, and navigate Git's safety nets.
Set up a fresh repository with some initial content to practice undoing changes safely.
mkdir -p ~/git-practice/lesson-301
cd ~/git-practice/lesson-301
git init
echo "# Undoing Changes Practice" > README.md
git add README.md
git commit -m "Initial commit"
We're creating a clean slate with an initial commit. This gives us a starting point to practice various undo operations.
You should have a new repository with one commit containing README.md.