Happy Holidays! from eMexo Technologies.. Call us (+91 9513216462) to get 30% discount now!

All Courses
Git Reset

The git reset command is a complex and versatile tool for undoing your changes. There are three main forms of invocation. These formats correspond to the command line arguments –soft, -mixed, and -hard. Each of the three arguments corresponds to Git’s three internal state management systems.
The mechanism, commit tree (HEAD), staging index, and working directory.

Git Reset - architecture

Git reset at least changes where the current branch (HEAD) points. The difference between –mixed and –soft is whether the index also changes.

Git tree

–soft: Revert the changes, the changes will remain staged (index).
–mixed (default): Uncommit + unstage changes, The changes remain in the working tree.
–hard: Uncommit + Unstaging + Delete Changes, nothing left.

Git Reset

Discard the files in the working area we will use git checkout <filename> if you want all git checkout.
Discard the staged (after git add .) files using the git_reset HEAD * or the git_reset HEAD filename Remove the committed messages using git reset HEAD~1

git reset --soft HEAD~1 --> --soft option will remove commit still files kept in staged area and working area.
git reset HEAD~1 --> by default it's a mixed option it will undo your staging area and keep it working directory
git reset --hard HEAD~1 --> --hard option will remove commits and also files removed in the staged area and working area both.