0
0
Gitdevops~10 mins

post-merge hook in Git - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a post-merge hook script that prints a message after merging.

Git
#!/bin/sh
 echo "[1]"
Drag options to blanks, or click blank then click option'
AMerge completed successfully!
Bgit merge
Cmerge finished
Dpost-merge hook
Attempts:
3 left
💡 Hint
Common Mistakes
Using git commands inside the hook without proper syntax.
Not making the script executable.
Printing nothing or an unclear message.
2fill in blank
medium

Complete the code to make the post-merge hook executable.

Git
chmod [1] .git/hooks/post-merge
Drag options to blanks, or click blank then click option'
A777
B644
C-x
D+x
Attempts:
3 left
💡 Hint
Common Mistakes
Using numeric permissions instead of symbolic.
Using '-x' which removes execute permission.
Not setting executable permission at all.
3fill in blank
hard

Fix the error in the post-merge hook script to correctly run a command after merge.

Git
#!/bin/sh
 git [1]
Drag options to blanks, or click blank then click option'
Apush
Bcommit
Cstatus
Dmerge
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to run 'git merge' inside the post-merge hook.
Running 'git push' which may cause unexpected behavior.
Running 'git commit' without staged changes.
4fill in blank
hard

Fill both blanks to write a post-merge hook that updates submodules and prints a message.

Git
#!/bin/sh
 git [1] --recursive
 echo "[2]"
Drag options to blanks, or click blank then click option'
Asubmodule update
Bsubmodule init
CSubmodules updated successfully!
DMerge completed
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'submodule init' instead of 'submodule update'.
Not printing any message after updating.
Forgetting the --recursive option.
5fill in blank
hard

Fill all three blanks to create a post-merge hook that logs the merge time, updates submodules, and prints a message.

Git
#!/bin/sh
 echo "Merge done at $(date)" >> merge.log
 git [2] --recursive
 echo "{{BLANK_3}}"
Drag options to blanks, or click blank then click option'
Adate
Bsubmodule update
CSubmodules updated successfully!
Dgit status
Attempts:
3 left
💡 Hint
Common Mistakes
Not logging the date correctly.
Using wrong git commands for submodules.
Not printing a confirmation message.