Hi I am curious about the difference between these two commands. When they introduce here: https://www.atlassian.com/git/tutorials/undoing-changes
Looks like git reset --hard
also sets both the staging and the working directory to match the latest commit, but in the end they say that git reset --hard
won't change the current working directory. So I am very confused here, can someone clarify it?
They do two different things . Let say , you did
GIT PULL
and then started editing some files and probably have added and commited those changes to the be pushed ... and then for some reason you decided to just discard all the changes that have been made to the given files and go back an earlier state . in the case you will doChoose the commit that you want to roll back to, like so:
after resetting HEAD , all changes/staged files will be gone.
As for git clean . Below is how git-scm.com describes it.
More about reset vs clean and their --options
VS