Challenge - 5 Problems
Post-Merge Hook Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate1:30remaining
Output of a post-merge hook script
Given the following
post-merge hook script in a Git repository, what will be the output after a successful merge?Git
#!/bin/sh echo "Merge completed on $(date)"
Attempts:
2 left
💡 Hint
The
date command outputs the current date and time in a default format.✗ Incorrect
The script uses command substitution $(date) which runs the date command and inserts its output. The default format of date is a full date and time string like 'Thu Jun 1 12:00:00 UTC 2024'.
🧠 Conceptual
intermediate1:00remaining
Purpose of the post-merge hook
What is the primary purpose of the Git
post-merge hook?Attempts:
2 left
💡 Hint
Think about what happens after a merge finishes successfully.
✗ Incorrect
The post-merge hook runs after a successful merge and is typically used to update files, rebuild assets, or notify users about the merge completion.
🔀 Workflow
advanced1:30remaining
Correct placement of a post-merge hook script
Where should you place a custom
post-merge hook script in a Git repository to ensure it runs after merges?Attempts:
2 left
💡 Hint
Git looks for hooks in a specific directory inside the repository.
✗ Incorrect
Git expects hook scripts to be placed inside the .git/hooks directory with the exact hook name and executable permissions.
❓ Troubleshoot
advanced1:30remaining
Why does the post-merge hook not run?
You created a
post-merge hook script in .git/hooks/ but it does not run after merges. Which is the most likely reason?Attempts:
2 left
💡 Hint
Git requires hook scripts to have a specific permission to run.
✗ Incorrect
Git only runs hook scripts if they have executable permissions. Without it, the script is ignored.
✅ Best Practice
expert2:00remaining
Best practice for sharing post-merge hooks across a team
What is the best practice to share a
post-merge hook script with all team members in a Git project?Attempts:
2 left
💡 Hint
Git does not track files inside .git/hooks by default.
✗ Incorrect
Since .git/hooks is not version controlled, the best practice is to store hook scripts in the repository (e.g., in a hooks/ folder) and provide a setup script that copies them to .git/hooks/ for each user.