If I make changes to the working tree and have not yet committed, and I would like to revert the changes I have made, is there a difference between
git reset --hard HEAD
and
git checkout .
?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
git checkout -- .will obviously only work on the current directory (and subdirectories thereof),git reset --hardwill operate on the complete working tree.git checkout -- .will only update the working tree and leave already staged files as is, whereasgit reset --hardwill match index and working tree with the HEAD commit.when used with a refspec:
resetwill set the current branch head to the given commit (and matches index and working tree)checkoutwill switch to that branch, leaving local changes intact, when they touch files which did not change between the current branch and the branch to be checked out