DEV Community

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

Posted on

5

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)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more