Don't have the rep to comment on other answers yet, I just wanted to add that I came across a case where the two commands do NOT have the same effect. I got into a weird state so this is definitely an edge case. Here is what happened:
I was in a branch, everything clean. I checked out master git checkout master
and found from git status
that there were changes to existing files not staged for a commit(yes, on the code I just checked out). I tried stashing to go back to a clean state, the stash claimed to have completed but git status
still was unchanged. Also tried git reset --hard HEAD
. It too reported successfully completing yet the status was no different. I could not abort these weird changes.
However, git checkout -f
solved this. I was able to get away from this strange state. So, in at least some ways, the two are not the same.