Git: How to revert changes in a single file or in all files

If you have modified or deleted a file by mistake on a git tracked project, you can still revert your action and reset the file like this:

For a single file (file.txt)

git checkout file.txt

For all files

You may just want to revert all your changes altogether, to do so, fire this command:

git reset --hard

# for help, type "git help reset"

Leave a Reply

Your email address will not be published. Required fields are marked *