Member-only story

Git Reset & Revert: A Comprehensive Guide

Explore practical examples of soft, mixed, and hard resets, and learn how to effectively manage your project’s history using Git reset and revert.

Mohammad Mahmudul Hasan
3 min readFeb 10, 2025

Introduction

Git provides powerful commands to undo changes, whether you need to modify a recent commit, remove a commit entirely, or reverse changes safely. Two primary commands for this are git reset and git revert. Understanding their differences is crucial for effective version control.

1. Git Reset

git reset moves the HEAD pointer to a previous commit, effectively undoing commits. It can optionally keep or discard changes from the staging area and working directory.

Syntax:

git reset [option] <commit>

Reset Modes & Usage

Example Usages

1. Undo the last commit but keep changes staged (before push)

--

--

Mohammad Mahmudul Hasan
Mohammad Mahmudul Hasan

Written by Mohammad Mahmudul Hasan

A learner, constantly striving to learn new technologies and look the ways to be better in this rapidly changing industry.

No responses yet