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?
git
does not intrinsically support what you're asking for.You could write a script or Bash function called
git
and put that ahead ofgit
in yourPATH
. The script or function would just check for "forbidden commands" and otherwise run the regulargit
program (e.g./usr/bin/git
).