I presume
git checkout .
deletes all unstaged edits because — is optional in:
git checkout [-p|--patch] [<tree-ish>] [--] [<paths>...]
This seems like something I might typo and there’s no “are you sure?” check, even in git-config as far as I can see. And since those changes haven’t ever been committed, they’re of course not in the reflog, so there’s no way to get them back.
Any way to make it prompt me before deleting my unstaged edits?
I’ve made a TextExpander snippet that rewrites git checkout . as #git checkout ., but hopefully there’s a better way.
You can add an alias and convience yourself to use that instead. IE, create this shell script:
and call it
git-safecheckout, and then alias it to something likeco:And the
git coinstead:[Obviously there are a million ways you can feature-creep that shellscript]