Conceptually, reset
is erasing your last change while revert
is adding a new change that undoes your previous change.
Imagine we are adding numbers:
8 + 26
and we keep adding additional numbers
8 + 26 + 7
and so on
8 + 26 + 7 + 53
but then we make a mistake and add an incorrect number (in this case we accidentally add 13
)
8 + 26 + 7 + 53 + 13
we can either erase our last change (git reset
) and pretend it never happened.
8 + 26 + 7 + 53
or we can add a new number that undoes the previous number (git revert
)
8 + 26 + 7 + 53 + 13 + (-13)
Leave a Reply