LaravelTips and TricksTipsTesting

Feb 15, 2024

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

By Vladimir Nikolic, CEO Coding Wisely

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.

Other posts:

Laravel.rs Meetup #1: A New Era for the Serbian Laravel Community
Laravel
Laravel.rs Meetup #1: A New Era for the Serbian Laravel Community

On May 10th, 2025, Laravel.rs officially launched its first-ever meetup in Temerin, bringing together developers from across Serbia for a night of lightning talks, community networking, and a shared love for Laravel. With inspiring talks, open discussions, and future plans for workshops and hackathons, this kickoff event marked the beginning of a vibrant new chapter for Laravel in Serbia. 🚀🇷🇸

Vladimir NikolicVladimir Nikolic
May 15, 2025
Code, Stress, and Recovery: My Path to a Healthier Developer Life
Tips and Tricks
Code, Stress, and Recovery: My Path to a Healthier Developer Life

For years, I ignored the signs of burnout—long hours, constant stress, and the fear of failure. It caught up with me. I landed in the emergency room. This is my story of hitting rock bottom and rebuilding my health, mindset, and career.

Vladimir NikolicVladimir Nikolic
Feb 28, 2025
How to use git hooks to run scripts before the committing code to repo
LaravelTips and Tricks
How to use git hooks to run scripts before the committing code to repo

Make sure that all and everything you want to run before the pushing code to production, works as you expect. Simply use git hooks.

Vladimir NikolicVladimir Nikolic
Feb 15, 2024

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