I want to amend the latest commit with the output of some automated script before the push, but for the push to include the latest change. Using husky I've written this:
"husky": {
"hooks": {
"pre-push": "yarn my-script"
}
}
where
"my-script": "custom-script && git add changed.file && git commit --amend --no-edit"
The problem with it is that push still works with the commits before the latest amended change - which makes sense to some extent.
Is it possible to do with git-hooks?
pre-push hook can be used to prevent a push but it cannot change commits being pushed. You need one of the pre-commit hooks.
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