git reset command

We can use git reset command to remove the commits from the branch.

Syntax git reset <option> <commit-hash>

The git reset has three optionss:
a) --soft: reset only HEAD

Syntax git reset --soft <commit-hash>

b) --mixed (default behavior): reset HEAD and index Syntax git reset <commit-hash>
or
git reset --mixed <commit-hash>

The above command will remove the commits in front of specified hash.

Note: The changes in the files are not reset to that commit, only the commit history is wipe out upto that commit.

c) --hard: reset HEAD, index and working tree
If we want to undo both the commits AND the actual changes in our files, we can use the --hard option.
For example, git reset --hard HEAD~1 will delete the last commit and associated changes. Be cautious when using this option as it permanently discards uncommitted changes.

Syntax git reset –hard <commit-hash>