0
0
Gitdevops~5 mins

Creating custom hook scripts in Git - Quick Revision & Summary

Choose your learning style9 modes available
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?
Aroot folder of the project
B.git/hooks folder
Cany folder in your home directory
Dinside the .gitignore file
What command makes a Git hook script executable?
Achmod 777 <hook-script>
Bgit hook enable <hook-script>
Cchmod +x <hook-script>
Dgit run-hook <hook-script>
Which hook runs before a commit is finalized?
Apost-merge
Bpost-commit
Cpre-push
Dpre-commit
What happens if a pre-commit hook script returns a non-zero exit code?
AThe commit is stopped
BThe commit proceeds normally
CGit deletes the commit
DGit ignores the hook
Which language can you use to write Git hook scripts?
AAny scripting language like Bash, Python, or Perl
BOnly Git's own language
COnly compiled languages like C
DOnly JavaScript
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.