Sometimes, you just want to get rid of whatever it is you did. Whether you just want to clean your working directory or you want to actually undo some items you (accidentally) committed, Git makes it possible.
There are a couple of scenarios we can think of that we want reverted. The first is quite simple. We have staged some files and we simply want to unstage everything. The git reset command does this:
git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: accidentally added.txt
modified: kernel.txt
deleted: lasers.txt
git reset
Unstaged changes after reset:
M kernel.txt
D lasers.txt
git status
On branch master
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory...