What is the difference between the following commands to undo changes in a local file?
git checkout HEAD <file>
git reset <file>
git checkout -- <file>
What is the difference between the following commands to undo changes in a local file?
git checkout HEAD <file>
git reset <file>
git checkout -- <file>
From git-checkout we can see that 1. and 3. are the same. Also both the working tree and the index is updated:
git checkout [<tree-ish>] [--] <pathspec>…
Overwrite paths in the working tree by replacing with the contents [..] in the <tree-ish> (most often a commit). When a <tree-ish> is given, the paths that match the <pathspec> are updated both in the index and in the working tree.
From git-reset, we see that only the index is updated:
git reset [-q] [<tree-ish>] [--] …
[...] copy entries from <tree-ish> to the index.