git checkout -- filename.js
undo a specific filegit checkout -- .
undo all filesRevert only reverts the changes in a specified commit. So if you are reverting a commit that happened 9 commits ago, it’ll only revert that particular commit and take it out and the other 9 commit changes still remain in place. It only reverts (undo) the specified commit.
Revert and commit the change
1git revert CommitIDXXXXXX
Revert, review the changes and then manually commit
1git revert -n CommitIDXXXXXX
this does not delete the commits that you are reverting, the other changes are preserved and you can see them in the git log.
reset
is destructive, you lose the other changes and they don’t show in git log.
1git reset CommitIDXXXXXX
2git reset --hard CommitIDXXXXXX
takes you back in time, and gets rid of any changes that are newer than the point you reverted to.
use the shortcut -t
flag
1git checkout -t origin/branchName