Is it possible to have git check the remote branch in the prepare-commit-msg
hook and see if the current commit is an amend, and if so, abort the commit?
That way it makes sure that you can not amend a commit that you already pushed, which would be handy.
There is no way to prevent someone doing git commit --amend
on their own machine.
You can however prevent people from force pushing git push --force
and rewriting the repository history. This is done with a server side hook e.g. see Github's Blocking force pushes to a repository.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With