Husky is a tool that helps you run scripts automatically before Git actions like commit or push. It makes sure everyone on the team runs the same checks.
Click to reveal answer
beginner
How does Husky help share Git hooks with a team?
Husky stores hook scripts in the project configuration, so when team members clone the repo and install dependencies, the hooks are set up automatically on their machines.
Click to reveal answer
intermediate
Where do you define Husky hooks in a project?
You define Husky hooks in the package.json file under the "husky" section or in separate hook files managed by Husky in the .husky directory.
Click to reveal answer
beginner
What command do you run to install Husky hooks after cloning a repo?
You run `npm install` or `yarn install` to install dependencies, and Husky will automatically set up the Git hooks defined in the project.
Click to reveal answer
beginner
Why is sharing Git hooks with Husky better than manually setting hooks?
Because Husky automates hook setup, it avoids mistakes and ensures all team members use the same checks without extra manual steps.
Click to reveal answer
What does Husky primarily help with in Git?
ARunning scripts automatically before Git actions
BMerging branches automatically
CCreating new Git repositories
DBacking up Git data
✗ Incorrect
Husky runs scripts automatically before Git actions like commit or push to enforce checks.
Where are Husky hooks usually defined?
AIn the package.json or .husky directory
BIn the .gitignore file
CIn the README.md file
DIn the node_modules folder
✗ Incorrect
Husky hooks are defined in package.json under "husky" or in the .husky directory.
How do team members get Husky hooks after cloning a repo?
ABy manually copying hook files
BBy running npm install or yarn install
CBy running git init
DBy creating hooks themselves
✗ Incorrect
Running npm install or yarn install installs dependencies and sets up Husky hooks automatically.
Which Git action can Husky run scripts before?
Abranch
Bclone
Cfetch
Dcommit
✗ Incorrect
Husky commonly runs scripts before commit or push actions.
What is a key benefit of using Husky for Git hooks?
AAutomatically merges conflicts
BIncreases Git repository size
CEnsures consistent hooks for all team members
DRemoves the need for Git
✗ Incorrect
Husky ensures all team members have the same Git hooks set up automatically.
Explain how Husky helps share Git hooks with your team.
Think about how Husky makes sure everyone runs the same checks without manual setup.
You got /4 concepts.
Describe the steps a team member takes to get Husky hooks after cloning a repository.
Focus on what happens after cloning and installing dependencies.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of using Husky in a Git project?
easy
A. To share Git hooks easily with the whole team
B. To create new Git branches automatically
C. To merge pull requests without conflicts
D. To backup the Git repository to the cloud
Solution
Step 1: Understand what Git hooks do
Git hooks are scripts that run at certain points in Git workflows, like before commits.
Step 2: Identify Husky's role
Husky helps share these hooks easily among team members by managing them in the project.
Final Answer:
To share Git hooks easily with the whole team -> Option A
Quick Check:
Husky = Share Git hooks [OK]
Hint: Husky = sharing Git hooks with team [OK]
Common Mistakes:
Thinking Husky manages branches
Confusing Husky with backup tools
Assuming Husky merges pull requests
2. Which command correctly installs Husky hooks in your Git project?
easy
A. npm install husky
B. git husky add
C. husky install
D. husky init
Solution
Step 1: Recall Husky installation steps
First, you install Husky as a package (e.g., npm install husky), then you run husky install to set up Git hooks.
Step 2: Identify the command that sets up hooks
The command husky install creates the hooks folder and configures Git to use Husky hooks.
Final Answer:
husky install -> Option C
Quick Check:
Setup hooks = husky install [OK]
Hint: Use 'husky install' to set up hooks folder [OK]
Common Mistakes:
Using 'npm install husky' as hook setup
Trying 'git husky add' which is invalid
Confusing 'husky init' with 'husky install'
3. Given the commands below, what will be the result?