When I want some changes in my project and I want to return to the state of the last commit, I can use these both options. Do they actually do the same thing or is there any difference between them?
Here is the difference between the two commands:
git checkout .
This tells Git to checkout the current folder, whatever that is, from the current branch and replace the working folder with it. But this does not affect other areas of the working folder, nor does it involve the stage.
git reset --hard
This resets the entire working directory and stage to the HEAD of the current branch. You can think of this as effectively nuking everything which has happened since your last commit.
Generally speaking hard reset is something you won't use that often, whereas checking out files/folders from various places is more common.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With