Hi @Inderpreet, @Tej-Singh-Rana, @Chudo , @Ayman ,
I am trying to understand how can i create a xfusioncorp_media and commit the changes followed by creating a master branch only after since i am getting error when doing that
Steps done:
install git and set global config values [success]
Create a bare repository /opt/media.git . [success]
** git init --bare --shared=group media.git**
Clone /opt/media.git to /usr/src/kodekloudrepos . [success] git clone /opt/media.git /usr/src/kodekloudrepos
Copy the update file from /tmp to hooks/ in .git/ dir inside /kodekloudrepos dir [success]
Create a new branch xfusioncorp_media. /kodekloudrepos dir
1st attempt : git branch xfusioncorp_media. [ failed ] [fatal: Not a valid object name: ‘master’.]
2nd attempt: git checkout --orphan xfusioncorp_media. [ not sure if this is correct , but without master branch seems to be one way ]
Copy /tmp/readme.md to /kodekloudrepos dir and commit changes .
After adding and commiting readme.md , tried
git push origin
which threw an error like unable to push to url=/opt/media.git since that is the bare repo from which it was cloned . Should i create xfusioncorp_media as an orphan ?
Hi @Lakshmi ,
Currently the update hook fails to prevent push to master . Possibly the way i have set it up is incorrect
Initially when i cloned the bare repo to kodekloudrepos after copying update hook file to /opt/media.git/hooks/ dir , it did not clone/copy the update file to /usr/src/kodekloudrepos/.git/hooks/ dir . So i had to manually copy the file to /usr/src/kodekloudrepos/.git/hooks/ dir . Is that the way to setup the hook ?
Below is the current output showing that it is possible to push to master
[root@ststor01 hooks]# cat update
#!/bin/sh
if [ "$1" == refs/heads/master ];
then
echo "Manual pushing to this repo's master branch is restricted"
exit 1
fi[root@ststor01 hooks]# cd ../..
[root@ststor01 kodekloudrepos]# echo 'ehllo' > test2.txt
[root@ststor01 kodekloudrepos]# git add . ; git commit -m 'another commit'
[master d742eb2] another commit
1 file changed, 1 insertion(+)
create mode 100644 test2.txt
[root@ststor01 kodekloudrepos]# git branch
* master
xfusioncorp_news
[root@ststor01 kodekloudrepos]# git push origin master
Counting objects: 4, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 295 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To /opt/news.git
8246136..d742eb2 master -> master