husky icon indicating copy to clipboard operation
husky copied to clipboard

‘git commit —amend’ triggers precommit hook

Open oneill-c opened this issue 8 years ago • 3 comments

Running ‘git commit —amend’ to edit commit message triggers the husky precommit that I have set up in my package.json.

oneill-c avatar Jan 07 '18 17:01 oneill-c

That’s still a commit

alexeyten avatar Jan 10 '18 05:01 alexeyten

Thanks @alexeyten . After having a look at the official docs I believe you are right. It clearly states that this will 'Replace the tip of the current branch by creating a new commit.' - https://git-scm.com/docs/git-commit#git-commit---amend

I shall close this issue.

oneill-c avatar Jan 10 '18 21:01 oneill-c

It shouldn't be a commit until the message is actually amended. pre-commit is running before a developer gets a chance to edit the commit message, and if there are any validations running on the message, it'll continuously fail without the opportunity to update. I think this is an issue.

sam-araiza avatar Jan 25 '23 21:01 sam-araiza