34/100 Git Hook
The Nautilus application development team was working on a git repository /opt/demo.git
which is cloned under /usr/src/kodekloudrepos
directory present on Storage server
in Stratos DC
. The team want to setup a hook on this repository, please find below more details:
- Merge the feature
branch into the master
branch`, but before pushing your changes complete below point.
ssh natasha@ststor01
sudo -i
[root@ststor01 kodekloudrepos]# cd /usr/src/kodekloudrepos/demo
[root@ststor01 demo]# git branch
* feature
master
[root@ststor01 demo]# git checkout master
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
[root@ststor01 demo]# git merge feature
Updating 3dc3e8c..1f49589
Fast-forward
feature.txt | 1 +
1 file changed, 1 insertion(+)
create mode 100644 feature.txt
- Create a post-update
hook in this git repository so that whenever any changes are pushed to the master
branch, it creates a release tag with name release-2023-06-15
, where 2023-06-15
is supposed to be the current date. For example if today is 20th June, 2023
then the release tag must be release-2023-06-20
. Make sure you test the hook at least once and create a release tag for today's release.
vi /opt/games.git/hooks/post-update
#!/bin/bash
cd /opt/games.git
tag=release-$(date "+%Y-%m-%d")
git tag $tag
esc:wq!
chmod +x /opt/games.git/hooks/post-update
git push
git tag
git log
commit 886e2d5911a7639813e7ba6556501a243593bf70 (HEAD -> master, origin/master, origin/feature, feature)
Author: Admin <admin@kodekloud.com>
Date: Fri Oct 3 14:51:40 2025 +0000
Add feature
commit c71b729e6f6c8349cdb345aeb222f0f9c2650fd5
Author: Admin <admin@kodekloud.com>
Date: Fri Oct 3 14:51:39 2025 +0000
initial commit
Not a great lover of git tbh - I'd preferred to have been able to skip this but seeing as its a linear path on the KodeKloud Engineer website there was no option but to complete it prior to getting onto K8's.