Git rollback memo

Environment

Explanation

How to rollback each procedure of git

Solution

# rollback all unstaged modification
$ git reset --hard

# rollback staged files
# (in repository root directory)
$ git reset .

# rollback newest commit keep files modified and staged
# (go back to when 2nd newest commit happened)
$ git reset --soft HEAD^

# rollback commit and discard its changing
# (go back to when 2nd newest commit happened)
$ git reset --hard HEAD^