DEV Community

Cover image for Git Revert? Restore? Reset?
Jake Roggenbuck
Jake Roggenbuck

Posted on

Git Revert? Restore? Reset?

Git revert, restore, reset ???
Here is what they all do.

Git revert

Makes a commit that is the opposite changes of a specified commit.

Changes from commit abc

+ My name is Jake
Enter fullscreen mode Exit fullscreen mode

git revert abc

Creates a commit that removes the line added in commit abc.

- My name is Jake
Enter fullscreen mode Exit fullscreen mode

Git reset

You can unstage changes with git reset <filename>.

Git reset can change the commit history to remove commits when using --hard so be careful with this one!

Git restore

Git restore - restore a given file in your working tree

Want to undo an auto format for a given file?

Run git restore <filename>

Top comments (0)