Recall & Review
beginner
What is a
pre-push hook in Git?A
pre-push hook is a script that runs automatically before you push your changes to a remote repository. It can check your code or run tests to stop bad changes from being pushed.Click to reveal answer
beginner
Where do you place a
pre-push hook script in a Git project?You place the
pre-push hook script inside the .git/hooks/ folder of your project, and name it pre-push (no file extension).Click to reveal answer
beginner
What must you do to make a
pre-push hook script executable?You must give the script execute permission using
chmod +x .git/hooks/pre-push so Git can run it automatically.Click to reveal answer
intermediate
What happens if a
pre-push hook script exits with a non-zero status?Git will stop the push process, preventing your changes from being sent to the remote repository.
Click to reveal answer
beginner
Give an example use case for a
pre-push hook.A
pre-push hook can run automated tests or check code style before pushing. If tests fail, the push is stopped to keep the remote code clean.Click to reveal answer
Where is the
pre-push hook script located in a Git project?✗ Incorrect
The
pre-push hook script must be placed in the .git/hooks/ directory with the exact name pre-push.What does a
pre-push hook do if it exits with status 1?✗ Incorrect
If the
pre-push hook exits with a non-zero status like 1, Git stops the push to prevent unwanted changes.Which command makes a
pre-push hook script executable?✗ Incorrect
You use
chmod +x on the hook script to give it execute permission so Git can run it.When does the
pre-push hook run?✗ Incorrect
The
pre-push hook runs automatically right before Git sends your changes to the remote repository.Which of these is a common use for a
pre-push hook?✗ Incorrect
Running tests before pushing helps catch errors early and keep the remote code stable.
Explain what a
pre-push hook is and why it is useful.Think about what happens right before you send your code to others.
You got /4 concepts.
Describe the steps to create and enable a
pre-push hook in a Git project.Focus on file location, permissions, and script behavior.
You got /4 concepts.