Hi. After using the git checkout command, the changes are not show in the working directory. This is despite using the process outlined by tensor2. Any suggestions?
Try re-opening the file (use the wee folder icon near the tab with the file name). The file itself should have changed but like most text editors an open document is buffered or stored in a temporary folder somewhere so changing it in the background won’t update the text unless it’s reopened (when it’s loaded from the file again).
HEAD usually refers to most recent commit on your current branch (it can point elsewhere but only if you deliberately make it so). In this case you can just treat it as the last commit you made.
You can reset the entire directory but you tend not to use checkout for just that purpose (unless changing to historical commits but even that does not remove local changes). git reset tends to work better for the entire repo and checkout for single files or changing to historical commits. By default it won’t remove all recent changes (or newly tracked files) and you’d need to force it but that only affects tracked files anyway. Git really tries to stop accidental overwrites of local changes, you have to be very explicit about it.
Long story short, this is a valid usage of checkout that is worth knowing. If you’ve made numerous changes that you 100% want to remove I’d tend to use reset with certain flags instead.
Ah sorry if that wasn’t clear, yes that’s right. You could change the file to any commit by specifying the exact SHA, e.g. git checkout 3ff8xa11 file.txt.
Instead of having to find and type out part of the sha for your current commit, HEAD is just more convenient.