I have gotten into the bad habit of using git reset --hard regularly.
I now discovered that there is git reset --keep, and if I really need to delete something I could even do git stash && git stash drop.
So I'd like to either disable hard resets, or make them ask before they delete uncommitted changes irrecoverably, or at least create a backup. Can this be done without wrapping git in a shell function?
gitdoes not intrinsically support what you're asking for.You could write a script or Bash function called
gitand put that ahead ofgitin yourPATH. The script or function would just check for "forbidden commands" and otherwise run the regulargitprogram (e.g./usr/bin/git).