Some new developers have joined xFusionCorp Industries and have been assigned Nautilus project. They are going to start development on a new application, and some pre-requisites have been shared with the DevOps team to proceed with. Please note that all tasks need to be performed on storage server in Stratos DC.
-
a. Install git, set up any values for user.email and user.name globally and create a bare repository /opt/media.git.
-
b. There is an update hook (to block direct pushes to the master branch) under /tmp on storage server itself; use the same to block direct pushes to the master branch in /opt/media.git repo.
-
c. Clone /opt/media.git repo in /usr/src/kodekloudrepos/media directory.
-
d. Create a new branch named xfusioncorp_media in repo that you cloned under /usr/src/kodekloudrepos directory.
-
e. There is a readme.md file in /tmp directory on storage server itself; copy that to the repo, add/commit in the new branch you just created, and finally push your branch to the origin.
-
f. Also create master branch from your branch and remember you should not be able to push to the master directly as per the hook you have set up.
-
SSH into the Server:
ssh natasha@ststor01 sudo su
-
Install Git:
yum install git -y
-
Verify Git Installation:
git --version
Output should confirm Git is installed, e.g.,
git version 2.43.5
. -
Configure Global Git Settings:
git config --global user.email "[email protected]" git config --global user.name "natasha"
-
Create a Bare Git Repository:
git init --bare /opt/media.git
Output should confirm the repository is created, e.g.,
Initialized empty Git repository in /opt/media.git/
. -
Set Up the Update Hook:
sudo cp /tmp/update /opt/media.git/hooks/ sudo chmod +x /opt/media.git/hooks/update
-
Clone the Bare Repository:
git clone /opt/media.git /usr/src/kodekloudrepos/media
The warning about the empty repository is expected since it is bare.
-
Navigate to the Cloned Repository:
cd /usr/src/kodekloudrepos/media
-
Create and Switch to the New Branch:
git checkout -b xfusioncorp_media
Note: This command creates the branch and checks it out in one step. The previous approach you used was incorrect because
git branch
only creates a branch but does not switch to it. -
Copy the
readme.md
File:cp /tmp/readme.md .
-
Add and Commit the Changes:
git add readme.md git commit -m "added readme.md"
Output should confirm the commit, e.g.,
[xfusioncorp_media 5fbedf6] added readme.md
. -
Push the
xfusioncorp_media
Branch to Origin:git push origin xfusioncorp_media
Output should confirm the push, e.g.,
[new branch] xfusioncorp_media -> xfusioncorp_media
. -
Create the
master
Branch fromxfusioncorp_media
:git checkout -b master git push origin master
Note: Since the
update
hook is in place, you should not be able to push to themaster
branch directly. The push will be rejected by the hook, which is the expected behavior.