Recall & Review
beginner
What is a Git hook?
A Git hook is a script that Git runs before or after events like commits, pushes, or merges. It helps automate tasks.
Click to reveal answer
beginner
Where do you place custom Git hook scripts?
Custom Git hook scripts go inside the
.git/hooks folder of your repository.Click to reveal answer
beginner
How do you make a Git hook script executable?
You run
chmod +x <hook-script> to make the script executable so Git can run it.Click to reveal answer
beginner
Name two common Git hook types you can customize.
Two common hooks are
pre-commit (runs before a commit) and post-commit (runs after a commit).Click to reveal answer
intermediate
What happens if a
pre-commit hook script exits with a non-zero status?Git stops the commit process and shows an error. This lets you prevent bad commits.
Click to reveal answer
Where should you place a custom Git hook script?
✗ Incorrect
Git looks for hook scripts inside the .git/hooks folder of the repository.
What command makes a Git hook script executable?
✗ Incorrect
chmod +x sets the executable permission needed for Git to run the hook script.
Which hook runs before a commit is finalized?
✗ Incorrect
The pre-commit hook runs before the commit is saved, allowing checks or validations.
What happens if a pre-commit hook script returns a non-zero exit code?
✗ Incorrect
A non-zero exit code signals failure, so Git stops the commit to prevent errors.
Which language can you use to write Git hook scripts?
✗ Incorrect
Git hooks are scripts and can be written in any language your system can run.
Explain how to create and enable a custom pre-commit Git hook script.
Think about where the script goes and how Git runs it.
You got /4 concepts.
Describe what happens when a Git hook script fails during a commit.
Focus on the effect of the script's exit code.
You got /4 concepts.