Reputation: 199
I been researching but haven't had any exact luck on:
git add
?"So, here I am, wondering if there is a way I can have a pre-add, during-add, or post-add hook to add a linter. My work currently has one for post-commit which is pretty annoying because I have to amend each time something changes.
Upvotes: 6
Views: 687
Reputation: 10064
You could use a git alias:
First, to add a pre-add command, define the alias ladd
(linter+add):
git alias.ladd '! your-linter-command; git add'
.
Then you can use as the add
command: git ladd
PS: Pro Git book is the place to look for git information.
Upvotes: 2
Reputation: 36134
There is a pre-commit
hook which isn't during add
but during commit
. It is however run before other hooks during the commit process. It even runs before editing the commit message.
If it's for yourself you could also just create an alias and get in the habit of using that instead of plain add.
Upvotes: 1