Skip to main content

Posts

Showing posts with the label Git

Git Reset vs. Git Revert: How to Safely Undo Pushed Commits

  You have just pushed a commit to the shared   main   branch, and the CI/CD pipeline immediately turns red. Perhaps you introduced a critical bug, or worse, committed a configuration file that breaks the production build. The adrenaline hits. Your instinct is to scrub the mistake from existence immediately. You open your terminal, ready to type  git reset --hard . Stop. If you run that command on a public branch, you are about to create a massive synchronization headache for every other developer on your team. While  git reset  and  git revert  both "undo" changes, they function fundamentally differently at the object level. Choosing the wrong one destroys commit history and halts deployment pipelines. This guide explains the architectural differences between these commands, how to choose the right one for DevOps workflows, and the exact commands to execute. The Root Cause: Pointers vs. Anti-Commits To understand why  git reset  is dang...