LaravelTips and TricksTipsTesting

February 15, 2024

How to use git hooks to run scripts before the committing code to repo

By Vladimir Nikolic

How to use git hooks to run scripts before the committing code to repo

here iw how.

In root, run this:

touch .git/hooks/pre-commit

Then, make it executable:

chmod +x .git/hooks/pre-commit

#!/bin/sh
echo "Running Pint ... "
files=$(git diff --cached --name-only --diff-filter=ACM -- '*.php');
./vendor/bin/pint $files

git add $files

echo "Running Pest ..." ./vendor/bin/pest --parallel --processes=4

and that is all.

Are you set to create something extraordinary?

Ready to take the next step? Let's work together to transform your ideas into reality. Contact us today to discuss how we can help you create impactful, user-centered solutions that drive success.

Contact Us