Does someone know of a better way to re-checkout all files in the working directory than the following?
In other words, I want to force overwrite every file in the working directory, with the cached copy of a certain commit ref, regardless of whether or not the files have been modified.
Here's how I'm currently doing it:
rm -rf * git checkout <ref> .
This works, but deletes untracked files, and doesn't delete hidden
.files. Of course, I don't want to delete
.git, but I do want other
.files to be affected.
I could come up with a more complete way to delete all the files in the working directory, but a solution that stays within Git would be ideal.
Why I want to do this: changing AutoCRLF
Files have not been modified, but need to be rewritten from the cache.
The ref I'm using is simply HEAD, so
git checkout ., but I wanted to generalize the question to any commit or branch.
For this problem, let's assume that the working directory is clean (unmodified).
If you have changes, you can always
git stash before doing this.