Recall & Review
beginner
What is a
commit-msg hook in Git?A
commit-msg hook is a script that runs automatically after a commit message is entered but before the commit is finalized. It checks the commit message to ensure it meets certain rules or formats.Click to reveal answer
beginner
Where do you place a
commit-msg hook script in a Git repository?You place the
commit-msg hook script inside the .git/hooks/ directory of your repository, and it must be executable.Click to reveal answer
intermediate
What happens if a
commit-msg hook script exits with a non-zero status?If the
commit-msg hook script exits with a non-zero status, Git stops the commit process and shows an error message. This prevents the commit from being saved.Click to reveal answer
beginner
Give an example of a simple rule a
commit-msg hook might enforce.A simple rule could be that the commit message must start with a capital letter and be at least 10 characters long.
Click to reveal answer
beginner
How can you test a
commit-msg hook script?You can test it by trying to make a commit with different messages and seeing if the hook allows or blocks the commit based on your rules.
Click to reveal answer
Where is the
commit-msg hook script located in a Git repository?✗ Incorrect
The
commit-msg hook script must be placed inside the .git/hooks/ directory.What does a non-zero exit code from a
commit-msg hook script do?✗ Incorrect
A non-zero exit code stops the commit process and shows an error message.
Which of these is a valid use of a
commit-msg hook?✗ Incorrect
The
commit-msg hook is used to check the commit message format before committing.How do you make a
commit-msg hook script executable?✗ Incorrect
You must make the script executable with
chmod +x.What file does the
commit-msg hook receive as input?✗ Incorrect
The hook receives the path to the file containing the commit message as its first argument.
Explain how a
commit-msg hook can help maintain commit message quality.Think about how automatic checks can stop bad messages.
You got /4 concepts.
Describe the steps to create and enable a
commit-msg hook for message validation.Focus on script location, permissions, and testing.
You got /4 concepts.