How to undo a commit in git
Published in
4 min readJan 15, 2020
A lot of developers struggling with undoing commits in git. From time to time, one accidentally commits changes that should not be in the tree. I like to show you how to undo these changes, either locally or remotely.
Basically a file can be in three different states. It can be untracked, unstaged or staged. Untracked files have never been added to the tree yet — meaning they are completely new. Unstaged files are…