have a peek here Git Reset Explored
Git reset basically reverts the commit to previous version… Below the types of git reset.
Git checkout “branchname”
pop over here Git reset HEAD~2 : It will reset the path to two previous head. It removes the log completely
Git reset -–soft HEAD~1 : It will reset the head to previous commit, however leaves the files in the working directory (i.e unstaged files) to as it is… So basically when you do this, the files that were added in the commit will be moved back to staged state and also the files in the working directory, like unstaged files will be kept as it is. The other thing that needs to be kept in mind that if you do the commit immediately after this operation and specifically have made changes to the files in the untracked mode, then the file that were moved back to unstaged state and had also been change in the local working directory will directly be committed. It removes the log completely
Git reset -–mixed HEAD~1 : This reset the head to previous commit and unstaged the files that are marked for commit including the commit ones. Also doesn’t touch the files that are not marked for commit. This is the default option. this is like an undo operation where your changes are unstaged both already commit and staged.
Git reset -–hard HEAD~1: It basically reset the head to previous version and discard the changed files in the commit. This doesn’t touch the unstaged files. It removes the log completely
Git reset –keep HEAD~1: It will basically reset the working tree to set of files that is same between the commit that you have reverted and the commit where head has now moved in the working tree. If you find the some changes in the local working directory in the files that is supposed to be updated during git reset, then this will be aborted.
Git reset –merge HEAD~1: It will basically reset the working tree to set of files that is same between commit that you have reverted and the commit where head has now moved in the working tree. Same as git reset –keep, however will keep the file that has not been added to staged state. . If you find the some changes in the local working directory in the files that is supposed to be updated during git reset, then this will be aborted.
Below are the working examples for reference.
Git Revert Explored
Git revert the changes in the source control and do a new commit for the revert. Doesn’t alter the history.
Continue the operation in progress using the information in .git/sequencer. Can be used to continue after resolving conflicts in a failed cherry-pick or revert.
Forget about the current operation in progress. Can be used to clear the sequencer state after a failed cherry-pick or revert.
Cancel the operation and return to the pre-sequence state.