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
Following @perror's answer, I came up with the following:
parent=$(/bin/ps -o ppid -p $PPID | tail -1) if [ -n "$parent" ]; then amended=$(/bin/ps -o command -p $parent | grep -e '--amend') if [ -n "$amended" ]; then echo "This is an 'amend'" fi fi