Git Revert vs Git Reset
Git revert adds a new commit that undoes an old one, so the history stays. Git reset moves the branch back, so later commits drop off it. Use revert on shared branches, and reset only on your own work.
Git Revert
A new commit that undoes an old one. The old one stays in the history.
Git revert undoes a commit by making a new commit that does the opposite. If the old commit added a line, the new one takes it out. The old commit stays in the history. Nothing is deleted or rewritten. That makes it safe on a branch other people already have.
Git Reset
Moving a branch back to an earlier commit. Later commits drop out of it.
Git reset moves your branch back to an earlier commit. The commits after it drop out of the branch. The soft mode keeps their changes staged. The default, mixed mode keeps the changes in your files but unstaged. The hard mode throws the changes away, and that cannot be undone easily.
In one line
- Git Revert
- A new commit that undoes an old one. The old one stays in the history.
- Git Reset
- Moving a branch back to an earlier commit. Later commits drop out of it.