Suggested a Git Workflow Architecture to Manage the Product Release — Git Case Study 1

Visal Tyagi
DevOps-Guides
Published in
13 min readMay 30, 2024

--

Problem Statement:

You work as a DevOps Architect in Zendrix Softwares. The company has been struggling to manage their product releases. The releases should happen on the 25th of every month. Suggest a Git workflow architecture for this requirement. Simulate this workflow by creating pseudo code files and branches and upload the same to your GitHub account.

As a part of the solution, share the link to your GitHub repository.

Before moving this case study solution, if you have not checked the Git assignments, please check out these Git Assignment Solutions:

Create The Files & Push them to Git Hub Repository — Git Assignment 1

Create the Files in Separate Branches And Perform Stash & Unstash Operations — Git Assignment 2

Create & Delete the Branches in Git Hub from Local & Remote Repository — Git Assignment 3

Create Two Branches & Merge These Branches to the Master Branch — Git Assignment 4

Create a Git Workflow Architecture & Use Hotfix to Push a File — Git Assignment 5

Check the Git Hub Repository for this Assignment to Copy the Commands:

Proposed Git Case Study 1 Problem Solution

Follow these steps to implement a Git Workflow architecture to remove the product release struggle:

A. Suggested Case Study Workflow Architecture

Git Case Study 1 — Workflow Architecture
Git Case Study 1 — Workflow Architecture

In this case, we will create three separate branches “master”, “develop” & “feature”. The “develop” branch will be created from the “master” branch, while the “feature” branch will be created from the “develop” branch. Also, create three files such as “master.txt”, “develop.txt” & “feature.txt” in these respective branches.

After creating all the branches & files, we will merge the “feature” branch into the “develop” branch & after merging the “feature” branch, we will merge the “develop” branch into the “master” branch.

Merging all branches into a master means the final code is ready to release & company will easily release the final product on the 25th of every month using this strategy.

B. Create an EC2 Instance for Accessing the Git Environment

Step 1: Go to the “Services” section & search “EC2” here. Put the cursor over “EC2” & click on “Instances” here.

Search EC2 Here
Search EC2 Here

Step 2: Click on “Launch Instances”.

Launch Instance
Launch Instance

Step 3: Choose “Name” as “Git-Case-Study-1” in the “Name and tags” section.

Write Instance Name Here
Write Instance Name Here

Step 4: Choose “AMI” as “ubuntu”.

Ubuntu AMI
Ubuntu AMI

Step 5: Choose “Instance type” as “t2.micro”.

Choose the Instance type
Choose the Instance type

Step 6: Choose “key pair (name) — required” as “Demo”.

Choose key pair (login)
Choose key pair (login)

Step 7: In “Network Settings”, choose “Select existing security group” in the “Firewall (security groups)” & while choosing “Common security groups” as “launch-wizard-9”.

Choose the Security Group
Choose the Security Group

Step 8: Click on “Launch Instance” in the “Summary”.

Click “Launch instance”
Click “Launch instance”

Step 9: The “Instance” will be successfully launched, click on “hyperlink (i-000fa73460f04612d).

Click Hyperlink
Click Hyperlink

Step 10: The Instance “Git-Case-Study-1” will be in the “Running” State.

Instance in the “Running State”
Instance in the “Running State”

Step 11: Select the Instance & Click on “Connect”.

Select the Instance
Select the Instance

Step 12: Again, click on “Connect”.

Click on “Connect”
Click on “Connect”

Step 13: First, update the machine using the below-given command:

sudo apt-get update
Update the machine
Update the machine

Step 14: The machine will be successfully updated.

Machine Updated Successfully
Machine Updated Successfully

C. First Create a master.txt File in the Master Branch

Step 1: First, create a file named “master.txt” file using the below-given command:

nano master.txt
Create a “master.txt” file
Create a “master.txt” file

Step 2: Write the line here: “This is a master.txt file”.

Write file description here
Write file description here

Do “CTRL+X” to exit & press “Yes” to save the file from the keyboard. Press “enter” from the keyboard to completely exit from the “master.txt” file.

Step 3: Now, initialize the git environment using the below-given command:

git init
initialize the Git Repository
initialize the Git Repository

Step 4: Now, add or stage the file (master.txt) in “Git” using the below-given command:

git add master.txt
Stage the “master.txt” file
Stage the “master.txt” file

The “master.txt” file has been successfully staged.

Step 5: Commit the changes to the local machine using the below-given command:

git commit –m "committing master.txt file".
Commit the “master.txt” file
Commit the “master.txt” file

Step 6: Run the below-given command to check out the branch:

git branch
Check the branches
Check the branches

Step 7: Run the below-given command to check out the branch:

git checkout master

Run the below-given command to check how many files are present in the master branch:

ls  
Checkout the files
Checkout the files

You will notice that “master.txt” will be shown here.

D. Create the develop branch with the develop.txt file

Step 1: First, we will create a develop branch using the below-given command:

git branch develop

Also, run the below-given command to check how many branches are present:

git branch
Create a develop branch
Create a develop branch

You will notice that the “develop” branch will be displayed here.

Step 2: To create the “develop.txt” file, we have to switch to the “develop” branch.

Use the below-given command to go to the “develop” branch:

git checkout develop
Go inside the “develop” branch
Go inside the “develop” branch

Step 3: Create the file using the below-given command:

nano develop.txt
Create a develop.txt file
Create a develop.txt file

Step 4: Write a line here: This is a develop.txt file

Write the file description here
Write the file description here

Do “CTRL+X” to exit & press “Yes” to save the file from the keyboard. Press “enter” from the keyboard to completely exit from the “develop.txt” file.

Step 5: Stage the “develop.txt” file using the below-given command:

git add develop.txt
Stage the develop.txt file
Stage the develop.txt file

Step 6: Commit the changes using the below-given command to git local directory:

git commit –m "committing develop.txt file"
Committing the “develop.txt” file
Committing the “develop.txt” file

D. Create the feature branch with the feature.txt file

Step 1: First, we will create a feature branch using the below-given command:

git branch feature

Also, run the below-given command to check how many branches are present:

git branch
Create a feature branch
Create a feature branch

You will notice that the “feature” branch will be displayed here.

Step 2: For creating the “feature.txt” file, we have to go to the “feature” branch.

Use the below-given command to go to the “feature” branch:

git checkout feature
Go to the “feature” branch
Go to the “feature” branch

Step 3: Create the file using the below-given command:

nano feature.txt  
Create a feature.txt file
Create a feature.txt file

Step 4: Write a line here: This is a develop.txt file

Feature.txt file content
Feature.txt file content

Do “CTRL+X” to exit & press “Yes” to save the file from the keyboard. Press “enter” from the keyboard to completely exit from the “feature.txt” file.

Step 5: Stage the “feature.txt” file using the below-given command:

git add feature.txt
Stage the feature.txt file
Stage the feature.txt file

Step 6: Commit the changes using this command to git local directory:

git commit –m "committing feature.txt file"
Commit the “feature.txt” file
Commit the “feature.txt” file

E. Create a Git Hub Repository on a Git Hub Account & Upload the Git Workflow Architecture

Step 1: Login into your GitHub Account using your username & password.

Login into the GitHub
Login into the GitHub

Step 2: Click on “New”.

Create a New Repository
Create a New Repository

Step 3: Choose the following options during repository creation:

Repository name: Git-Case-Study-1

Description: Git-Case-Study-1

Choose “Public” Here.

Repository Name and Description
Repository Name and Description

Step 4: Choose the “Add a README file” option & click on “Create repository”.

Choose Add a README.md file option
Choose Add a README.md file option

Step 5: Repository (Git-Case-Study-1) has been successfully created.

Repository Created Successfully
Repository Created Successfully

Step 6: Click on “Add file > Upload files”.

Upload the file
\Upload the file

Step 7: Click on “Choose your files”.

Choose the files
Choose the files

Step 8: Select the “Case Study Architecture Image” & click on “Open”.

Choose the “Case Study Architecture” Image
Choose the “Case Study Architecture” Image

Step 9: The file will be successfully uploaded, click on “Commit Changes”.

Commit the Changes
Commit the Changes

Step 10: The “Case Study Architecture” image will be successfully uploaded.

Case Study Architecture Image Upload
Case Study Architecture Image Upload

F. Add SSH Keys to Your Git Hub Account

Step 1: Go to “EC2 Instance (Git-Case-Study-1)” & go to the .ssh directory using the below-given command:

cd .ssh/
Go to the .ssh directory
Go to the .ssh directory

Step 2: Type the below-given command to generate the public & private keys:

ssh-keygen

Press “enter” from the keyboard three times.

A public & private key will be successfully generated.

Generate the public & private keys
Generate the public & private keys

Step 3: Run the below-given command to copy the “id_rsa.pub” content:

sudo cat id_rsa.pub
Open the id_rsa.pub file
Open the id_rsa.pub file

Step 4: Go to the “Git Hub Account” & click on “Profile picture”. Scroll down & click on “Settings”.

Go to profile
Go to profile

Step 5: Click on “SSH and GPG Keys”.

Go to “SSH and GPG Keys”
Go to “SSH and GPG Keys”

Step 6: Click on “New SSH Key”.

Create a New SSH Key
Create a New SSH Key

Step 7: Choose the following options here:

Title: SSH Keys

Key type: Authentication Key

Key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDe5RitJQ2oDtxT6HFzgFekE1f4EZX3vSgCTZTKhkDdjS7cTbsNAb1ZfQKgRgI9ZtPHgl0utozGvImrmuXkhRgqCIEBeBNJGe5gOBjp3iFs1RsbJFG5mdAi+VnMqWTyKi8FcZZx9OJ8wS7YMEnUOowsc2x+43wpQ0rGG2DBOsUbtDDSUoMG8M2jLfNZk8Km4pVM6jET4TpB01TTT0hhhDLCGQZVKGfD89wmfJrhLGnNGbkZfOziRv5UYRNlDbCNQgAVlPF+/m/UFDxBlrVWKVPxy96vpj/I4us7EniBcKBL7b57JBgS6rGZ0pNDqgh3zPN+vqJYytKmKD+oigu893ke6yuF1iQ2zgKAGXBNdPNpZCpX/tVJKETIjmjInWioJffunAyYSimJ0egDTt5hRMlaNUY9/VcAmOhSsAAn6XazknoJ17cNLOUxDyfsOeNroSTOcNZ6CV8d5klXUmt2Y5Gen1T+sGue7GfmmI8vsSqclsygplB52biCfXqVjY3oaG8= ubuntu@ip-172–31–39–87

Click on “Add SSH Key”.

Add SSH Key
Add SSH Key

Step 8: The “SSH Key” will be successfully added.

SSH Key Added
SSH Key Added

G. Fetch the Remote Repository to EC2 Instance

Here, we will first the remote repository (Git-Case-Study-1) to the local machine & push all local machine changes to the remote repository which is created on the “Git Hub” Account.

Step 1: First, you have to change the directory & come out from the .ssh directory using the below-given command:

cd ..
Come out to the .ssh directory
Come out to the .ssh directory

Step 2: Go to the “Git Hub Repo (Git-Case-Study-1) & click on “Code”. Go to “SSH” & copy the code by clicking on the icon.

Go to the SSH Section
Go to the SSH Section

Step 3: Run the below-given command to fetch the remote directory “Git-Case-Study-1”:

git remote add Git-Case-Study-1 git@github.com:visaltyagi/Git-Case-Study-1.git
Add Remote Repository to the Local Machine
Add Remote Repository to the Local Machine

Step 4: Run the below-given command to check whether the repository is fetched or not:

git remote -v
Remote Repository Added or Not
Remote Repository Added or Not

H. Push All the Branches to the Git Hub Account

Step 1: First, we will push the “master” branch to the remote repository (Git-Case-Study-1) using the below-given command:

git push Git-Case-Study-1 master
Push “master” branch to the remote branch
Push “master” branch to the remote branch

Type “yes” to continue. The “master” branch will be successfully pushed to the “Git Hub Account”.

Step 2: Go to the “Git Hub Account” & choose the “master” branch. The “master.txt” file will be shown.

master branch pushed to the remote repository
master branch pushed to the remote repository

Step 3: Now, we will push the “develop” branch to the remote repository (Git-Case-Study-1) using the below-given command:

git push Git-Case-Study-1 develop
Push the “develop” branch to the remote repository
Push the “develop” branch to the remote repository

The “develop” branch will be successfully pushed to the “Git Hub Account”.

Step 4: Go to the “Git Hub Account” & choose the “develop” branch. The “develop.txt” file will be shown.

“develop” branch pushed to remote repository
“develop” branch pushed to remote repository

Step 5: Now, we will push the “feature” branch to the remote repository (Git-Case-Study-1) using the below-given command:

git push Git-Case-Study-1 feature
Push the “feature” branch to the remote repository
Push the “feature” branch to the remote repository

The “feature” branch will be successfully pushed to the “Git Hub Account”.

Step 6: Go to the “Git Hub Account” & choose the “feature” branch. The “feature.txt” file will be shown.

feature branch successfully pushed to the remote repo
feature branch successfully pushed to the remote repo

I. Make Master Branch a Default Branch & Remove Main Branch from Git Hub Repository

Step 1: Go to the “Settings” in “Git-Case-Study-1”.

Go to the “Settings”
Go to the “Settings”

Step 2: Click on “Double Arrows” to switch the branch.

Click on “Double Arrows”
Click on “Double Arrows”

Step 3: Choose to “master” & click on “Update”.

Update the “master” branch here
Update the “master” branch here

Step 4: Click on “I understand, update the default branch”.

Agree with “I understand, update the default branch”
Agree with “I understand, update the default branch”

Step 5: Now, the default branch will be “master”.

“master” as a default
“master” as a default

Step 6: Click on “Code”.

Go to the code section
Go to the code section

Step 7: Click on the “4 Branches” hyperlink.

Click on “4 Branches”
Click on “4 Branches”

Step 8: Click on the “delete” icon.

Branches
Branches
Delete the main branch
Delete the main branch

Step 9: Now the “master” will be a default branch.

“master” as a default branch
“master” as a default branch

J. Merge All Branches to the master branch

Step 1: First, which branch we have accessed via the below-given command:

git branch
feature branch
feature branch

So, we are in the “feature” branch.

Step 2: Now, we will merge the “feature” branch into the “develop” branch. Go to the “develop” branch using the below-given command:

git checkout develop
Switch to the “develop” branch
Switch to the “develop” branch

We will successfully move to the “feature” branch.

Step 3: We will run the below-given command to merge the “feature” branch into the “develop” branch:

git merge feature
Merge feature with develop branch
Merge feature with develop branch

The “feature” branch will be successfully merged with the “develop” branch.

Step 4: First, we will go to the “master” branch using the below-given command:

git checkout master
Go to the “master” branch
Go to the “master” branch

We have successfully switched to the “master” branch.

Step 5: Now, we will merge the “develop” branch into the “master” branch. Go to the “master” branch using the below-given command:

git merge develop
Merge develop branch with master
Merge develop branch with master

Now, both “develop.txt” & “feature.txt” has been successfully moved to the “master” branch.

K. Again, Push All the Changes to the Develop & Master Branch in the Remote Repository

Step 1: Push all “develop” branch changes to remote repository “Git-Case-Study-1” using the below-given command:

git push Git-Case-Study-1 develop
Push develop branch to the GitHub Account
Push develop branch to the GitHub Account

Step 2: Go to the “develop” branch & “Git-Case-Study-1” repository. You will notice that “feature.txt” has been successfully merged into the “develop” branch.

develop branch
develop branch

Step 3: Push all “master” branch changes to remote repository “Git-Case-Study-1” using the below-given command:

git push Git-Case-Study-1 master
Push the “master” branch to the Git Hub Account
Push the “master” branch to the Git Hub Account

Step 4: Go to the “master” branch in the “Git-Case-Study-1”, both the “develop.txt” & “feature.txt” files will be shown here now.

master branch
master branch

Now, the code will be in the “Release state”, you can do your “DevOps operation” now.

Check the Following DevOps Case Studies Here

Resolve Merge Conflict in The GitHub Repository — Git Case Study 2

Containerized an HTML Website using Docker on Production Environment — Docker Case Study

Creating an Architecture using Terraform on AWS — Terraform Case Study

Integration of DevOps Tools with Jenkins — Jenkins Case Study

Create Two Server Groups & Install Apache on The First Group & NGINX on the Second Group — Ansible Case Study

How to Deploy a Sample Website on Kubernetes Using Ingress — Kubernetes Case Study

--

--