Understanding the Differences: GIT Reset vs. GIT Revert
GIT Reset
Let us know about what is Head pointer first
- Head Pointer - It points out the last commit to the current branch.
git reset
git reset is used to undo the changes from the Repository
git reset will reset the commit point to the previous commit point
git reset will not create any new commit point for tracking purpose
git reset is not recommended in shared repository
syntax
- git reset <reset_option> <previous_Commit_ID>
Reset options
git reset --soft <previous_Commit_ID>
git reset will reset the HEAD pointer to the previous commit point.
It will take the changes back to the commit area.
The changes will be available in staging area and working directory
git reset --mixed <previous_Commit_ID>
git reset will reset the HEAD pointer to the previous commit point.
It will take the changes back to the working directory.
The changes will be available only in the working directory.
git reset --hard <previous_Commit_ID>
git reset will reset the HEAD pointer to the previous commit point
It will permanently delete the files from the system
GIT Revert
git revert is same as git reset --hard option
git revert is used to undo a specific commit
git revert will create a new commit point for tracking purpose
git revert will maintain the commit history
git revert is recommended in shared repository
Syntax
git revert <specific_Commit_ID>