Can check if the level 4 lab 3 of git is working right?

Hi!

Recently I made a post requesting for help, and also another person as I see today. This days i had been working with this lab and apply many solutions that for my perspective, it seems fine. But for some reason not for the lab. Can you check if this lab is working right ? It seems that when you finally made the push, the tag didn’t work by the hook. I quite sure that what I’m doing should be fine, so please can you review this lab ? Thanks in advance!

Best regards

Hi @carlos140

Please give us more detail on the issue you are facing and how you try to do it ? Just testing all the lab and it’s work fine

Regard

Hi @mmkmou this is the steps that I’m doing:

after login by ssh and going to the folder:

cd .git/hooks

Then in the post-update.sample I put this:

!/bin/sh
#
# An example hook script to prepare a packed repository for use over
# dumb transports. 
#
# To enable this hook, rename this file to "post-update".

var1="release-"
var1+=$(date --rfc-3339=date)
git tag $var1

Then a edit the script name to post-update using mv
After that:

 git checkout master
 git merge features
 git push origin master
 git pull origin master

The tag is never inserted when you made the push operation.

Hi @carlos140

you should do this manipulation on bare repo folder

Hi @mmkmou . Thanks for the info, but I still don’t understand how to implement the bare repo. I tried many things, like changing the config file in .git, and setting the variable bare to true. Also I tried to create a empty bare repo, but I never could be able to linked the bare repo with the non bare repo in master branch. I checked this using git remote -v. Can you explain me how to link the bare repo with the non bare repo, in order to be able to run the hook script ?

Thanks for the help!

1 Like

Hi @mmkmou I’m still unable to make this task. Can you reply the previous question when you can ?

Thanks in advance and have nice day!

1 Like

Hi @carlos140 ,
Did you manage to get the solution for this?

Hi @harshgarg862000

Not yet, the last weeks I’m been studying the Kubernetes administrator course, but I think in the next couple of days I will return to find the solution.

As far as I know you need to implement the git hook in the bare repo, the /opt/iCantRememberTheRouteOfTheRepoWellEnough :upside_down_face: and not in the cloned repo, where the branch feature is. I think [maybe] I will check this lab in this weekend, I’m close to finish the CKA course, after that I will check the engineer plataform, because I want to finish the git labs to start the kubernetes. But when I’ll make it I will let you know if you like.

1 Like

Hi @mmkmou
Could you please advise how to do accomplish this as it is a bare repo and you are saying to do manipulation on bare repo folder? Please provide us with the steps to complete this task. Hoping to get a solution from your end.

It would be nice to know how to finish this lab, it seems many people are having trouble to solving this. I’m not getting yet in the engineer plataform because I’m focusing my study in getting the labs from the CKA course and exams well enough. But the last time I tried to accomplish this, I’m unable to do it, not sure if i try again I’ll succeed

Solution from my notes for git hook lab:

ssh [email protected]
cd /usr/src/kodekloudrepos/media/
sudo git checkout master
sudo git merge feature
sudo touch /opt/media.git/hooks/post-update
sudo chmod +x /opt/media.git/hooks/post-update
sudo vi /opt/media.git/hooks/post-update

#!/bin/bash
cd /opt/media.git
git_tag=release-$(date "+%Y-%m-%d")
git tag $git_tag

sudo git push

You must make hook on git repo host. In this case in git repo dir on the same host.

For git merge lab:

ssh [email protected]
cd ./story-blog/
git push (see error)
git pull (one file not merged)
vi ./story-index.txt

Edit this:
<<<<<<< HEAD
1. The Lion and the Mooose
2. The Frogs and the Ox
3. The Fox and the Grapes
4. The Donkey and the Dog
=======
1. The Lion and the Mouse
2. The Frogs and the Ox
3. The Fox and the Grapes
>>>>>>> ea1b54b88551502f5e6f60b9a74452a29bf2d09f
To this:
1. The Lion and the Mouse 
2. The Frogs and the Ox   
3. The Fox and the Grapes
4. The Donkey and the Dog

Make a commint:
git add .
git commit
git push

Login as sarah and check merged repo.

1 Like

Hi @carlos140
You must create the hook under the origin/bare repository, for example as per the below screenshot, the hook should be created under /opt/news.git/hooks/

Hi @bhard
Your solution for Git Hook works for me . Thanks

Thanks @uwithnishad that the @bhard solutions works. I’ll try it when I have some time to do it. I will link @harshgarg862000 to let him know also.

Have all of you a nice week.

Hi @carlos140
you can try now as it will hardly take 2 to 3 min.

Hi @uwithnishad

Thanks for let me know. Currently now I’m having to do a lot of tasks, so today maybe not, but during the week I’ll try. I’ll let you know if I succeed.

Sure @carlos140 and you will succeed.
Take care.

1 Like