How can I avoid an accidental dcommit from a local branch
问题 Sometimes, I create local branches in git, and I'd like to get a warning message when I try to dcommit from them. How can I prevent myself from accidentally dcommiting from a local branch? 回答1: An alternative to pre-commit hooks, if you're using Linux (or Git bash or Cygwin or similar), is to wrap git in a shell helper function. Add the below to your ~/.bashrc (for bash, Git bash) or ~/.zshrc (for zsh) file, or whatever the equivalent is for your shell: real_git=$(which git) function git { if