We can reverse changes in a Git repository using two commands: reset
and revert
. These commands could be used alongside with symbols# like ^
and ~
.
reset {commit}
is used on local Git repositories. It moves the current branch starting position to the specified commit and discards all changes after that commit. This results in a new commit history. All discarded commits could be still found in Git Reflog.
revert {commit}
is used on remote Git repositories. Instead of moving the branch starting position, it creates a commit that revert all the changes done by the commit and after it. No history will be changed other than having a new commit.