Undo working directory

If you want to undo any changes to working directory, user following command-

git checkout -- file.txt

Use — to undo a file in a current branch.

You may checkout specific commit or old version, use following command.

To see the commit user-

git log

Copy the first 10 characters of SHA and use following command to checkout a specific commit-

git checkout sha121212 -- file.txt

Where sha121212 is a SHA of the specific commit.

Amend commits

If you want to amend the commit i.e. something in the repository, you may do that using amend command. Note only the last/recent commit i.e. the HEAD point to can be amended and in this case date and SHA will be changes along with message, use following command-

git commit --amend -m "message goes here"

You may check the commit changes in log-

 git log

If you want to revert the current commit use following command-

git revert SHA21121

SHA21121 is the SHA for that commit.