Git Reset Practical Lab: Soft, Mixed, and Hard Resets Explained

🚀 GitHub for DevOps – Day 4 (Part 2) 🔥 Git Reset Practical — Hands-on Lab Let’s stop theory and actually see what happens 👇 🧪 Step 1: Create Repo mkdir git-reset-lab cd git-reset-lab git init 🧪 Step 2: Create Commits echo "Version 1" > file.txt git add . git commit -m "v1 commit" echo "Version 2" >> file.txt git add . git commit -m "v2 commit" echo "Version 3" >> file.txt git add . git commit -m "v3 commit" 👉 Current state: v1 → v2 → v3 🔥 PART 1: SOFT RESET git reset --soft HEAD~1 ✔ v3 commit removed ✔ Changes still staged 👉 Check: git status 💡 Perfect for fixing commit messages 🔥 PART 2: MIXED RESET git reset HEAD~1 ✔ Commit removed ✔ Changes remain in file ❌ Not staged 👉 You must run: git add . 🔥 PART 3: HARD RESET (⚠️ Dangerous) git reset --hard HEAD~1 ❌ Commit removed ❌ Changes deleted permanently 👉 File goes back to: Version 1 Version 2 🧠 Final Understanding Soft → Keep changes staged Mixed → Keep changes in files Hard → Delete everything 💬 If you cannot control Git history, you cannot survive in real DevOps environments. Follow for more real-world DevOps learning 🚀 #HiteshDevOps #DevOps #Git #GitHub #CI_CD #Docker #Kubernetes #AWS #OpenToWork #HiringDevOps #DevOpsEngineer #TechHiring   #LearningInPublic #BuildInPublic #TechJourney

  • No alternative text description for this image

To view or add a comment, sign in

Explore content categories