How to detect commit --amend by pre-commit hook ?

后端 未结 5 1308
陌清茗
陌清茗 2021-02-19 07:09

When I do commit --amend, it is unsafe commit if the commit already has been pushed to remote repository.

I want to detect unsafe commit --amend by pre-commit hook and a

5条回答
  •  忘掉有多难
    2021-02-19 07:23

    Following @Roger Dueck's answer, ended up doing:

    #./.git/hooks/prepare-commit-msg
    
    IS_AMEND=$(ps -ocommand= -p $PPID | grep -e '--amend');
    
    if [ -n "$IS_AMEND" ]; then
      return;
    fi
    

提交回复
热议问题