[Article by repo:
I created a simple calculator library, where I added an error hidden in one of the commits.
I need to identify what was the commit breaking the current implementation. Git bisect is the right tool for this job.
Watch the following screencast to see git bisect in action. The bottom terminal shows tests running in watch mode, while the top shows the current list of commits:
2. Start bisecting in the middle of the interval
4. Detect the bad commit
, here's a git hook that forces me to have my commit messages formatted in that way:
#!/bin/sh
# .git/hooks/commit-msg
commit_msg_file=$1
commit_msg=$(cat $commit_msg_file)
# Enforce conventional commit format
if ! echo "$commit_msg" | grep -qE "^(feat|fix|docs|style|refactor|test|chore)(\(.+\))?: .+"; then
echo "❌ Error: Invalid commit message format"
echo "----------------------------------------"
echo "Your message: '$commit_msg'"
echo "Required format: <type>(<scope>): <description>"
echo "Valid types: feat|fix|docs|style|refactor|test|chore"
echo "Example: feat(user-auth): add password reset functionality"
echo "----------------------------------------"
exit 1
fi
Here's what I see when the commit message is not right:
❌ Error: Invalid commit message format
----------------------------------------
Your message: 'Added new login feature'
Required format: <type>(<scope>): <description>
Valid types: feat|fix|docs|style|refactor|test|chore
Example: feat(user-auth): add password reset functionality
----------------------------------------
[Error: Git commit aborted due to invalid commit message format]
Key Takeaways
- Git aliases can significantly speed up your daily Git commands
- Git bisect is a powerful tool for finding problematic commits
- Git hooks help automate checks and maintain code quality
- All these features can be customized to match your team's workflow

SOCIAL SHARE CARD GENERATOR