What is a Git hook?

What is a Git hook?

a) A script that runs automatically before or after Git events
b) A tool for resolving merge conflicts
c) A command to check remote branches
d) A tag for annotating commits

Answer:

a) A script that runs automatically before or after Git events

Explanation:

A Git hook is a script that runs automatically before or after specific Git events, such as commits, merges, or pushes. Hooks allow you to automate tasks, such as running tests, formatting code, or enforcing coding standards.

For example, a pre-commit hook can be used to check for code formatting issues before a commit is made.

Hooks are powerful tools for ensuring code quality and enforcing development workflows.

Reference:

Top 100 Git and GitHub MCQ Questions and Answers

Scroll to Top