Git Undo Mistakes: Git Reset vs Git Revert

Day 25 of my DevOps & Git journey — and today hit different. 🚀 I learned how to UNDO mistakes in Git — one of the most important (and most feared) skills for any developer. 🔁 Git Reset vs Git Revert These two commands look similar but behave very differently: → git reset --soft  → Undo commit, keep changes staged → git reset --mixed → Undo commit, keep changes unstaged → git reset --hard  → Undo commit, DELETE the changes forever → git revert     → Undo safely by creating a NEW commit (safe for teams) The golden rule I learned today: Never use git reset on commits that are already pushed to a shared branch. Use git revert instead — it's safe, traceable, and won't break your teammates' work. 🌿 Branching Strategies used by real engineering teams I also researched how actual companies manage code at scale: ✅ GitFlow — Multiple branches (main, develop, feature, release, hotfix). Great for large teams with scheduled releases. ✅ GitHub Flow — Just main + feature branches. Simple, fast, perfect for startups shipping daily. ✅ Trunk-Based Development — Everyone commits to main. Used by Google, Meta, Netflix. Needs strong CI/CD and feature flags. Fun fact: React (by Meta) uses GitHub Flow — anyone in the world can fork it, fix a bug, and open a PR. Open source in action! 🌍 📁 Everything is documented in my GitHub repo: → day-25-notes.md with hands-on observations → git-commands.md updated with all commands from Days 22–25 [🔗https://lnkd.in/gCdzzCe4] [🔗 https://lnkd.in/gCKd7wqe] #Git #DevOps #90DaysOfDevOps #OpenSource #GitHub #LearningInPublic #Developer #BuildingInPublic #TrainWithShubham

  • No alternative text description for this image

To view or add a comment, sign in

Explore content categories