Complete the code to list the directory where client-side hooks are stored in a Git repository.
ls .git/[1]The client-side hooks are stored in the .git/hooks directory inside a Git repository.
Complete the command to create a server-side pre-receive hook file in the bare Git repository.
touch /srv/git/project.git/hooks/[1]The pre-receive hook is a server-side hook that runs before changes are accepted on the server.
Fix the error in the client-side hook script filename to make it executable by Git.
mv pre-commit.sample [1]Git recognizes client-side hooks by exact filenames like pre-commit without extensions or underscores.
Fill both blanks to create a client-side hook that prevents commits with empty messages.
#!/bin/sh if [ ! -s "$1" ]; then echo "Commit message is empty" >&2 exit [1] fi exit [2]
Exit code 1 signals failure to stop the commit if the message is empty. Exit code 0 means success to allow the commit otherwise.
Fill all three blanks to define a server-side hook that rejects pushes to the main branch.
#!/bin/sh while read oldrev newrev refname; do if [ "$refname" = [1] ]; then echo "Pushes to [2] are not allowed." >&2 exit [3] fi done exit 0
The hook checks if the refname equals refs/heads/main to detect pushes to the main branch. It prints a message with 'main' and exits with 1 to reject the push.