How to undo a commit in git

Christian Walter
ITNEXT
Published in
4 min readJan 15, 2020

--

Photo by Jim Wilson on Unsplash

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…

--

--

Writer for

Firmware Developer, Tech Enthusiasts. If you have questions about firmware — write me to christian.walter@9elements.com