0
0
Gitdevops~20 mins

post-merge hook in Git - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Post-Merge Hook Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1: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)"
AMerge completed on $(date)
BMerge completed on Thu Jun 1 12:00:00 UTC 2024
CMerge completed on 2024-06-01 12:00:00
DNo output
Attempts:
2 left
💡 Hint
The date command outputs the current date and time in a default format.
🧠 Conceptual
intermediate
1:00remaining
Purpose of the post-merge hook
What is the primary purpose of the Git post-merge hook?
ATo run commands after a successful merge to update the working directory or notify users
BTo reset the repository to a previous commit after merging
CTo automatically commit changes before merging
DTo prevent merges from happening if conflicts exist
Attempts:
2 left
💡 Hint
Think about what happens after a merge finishes successfully.
🔀 Workflow
advanced
1: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?
Aroot directory of the repository
B.git/post-merge
C.git/hooks/post-merge
Dany directory as long as it is executable
Attempts:
2 left
💡 Hint
Git looks for hooks in a specific directory inside the repository.
Troubleshoot
advanced
1: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?
AThe merge was done with --no-commit option
BThe script is named post-merge.sh instead of post-merge
CThe repository is not a Git repository
DThe script file is not executable
Attempts:
2 left
💡 Hint
Git requires hook scripts to have a specific permission to run.
Best Practice
expert
2: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?
AStore the hook script in the repository and use a setup script to copy it to .git/hooks/
BCommit the hook script directly inside .git/hooks/ directory
CAsk each team member to manually create the hook script locally
DUse a global Git hook directory for all repositories
Attempts:
2 left
💡 Hint
Git does not track files inside .git/hooks by default.