dev-ops-challenges

Git Create Branches

Technical Overview

Branches are one of the most powerful features in Git. A branch represents an independent line of development. By using branches, developers can work on new features, experiment, or fix bugs in isolation without modifying the main codebase (typically the master or main branch).

In a DevOps workflow:

This guide outlines the steps to SSH into the Storage Server (ststor01), navigate to the specified repository under /usr/src/kodekloudrepos/, switch to the master branch, and create a new feature branch named xfusioncorp_media.


Infrastructure & Configuration Requirements


Step-by-Step Implementation

Step 1: Connect to the Storage Server

From the Jump Host, establish an SSH session to the Storage Server (ststor01) using the natasha user credentials:

ssh natasha@ststor01

Step 2: Navigate to the Repository Directory

Navigate to the path of the target repository:

cd /usr/src/kodekloudrepos/media

(Note: Replace media with the specific repository directory assigned to you in the task description.)


Step 3: Handle Directory Ownership Permissions (If Required)

If you encounter git warnings about “dubious ownership” because the files are owned by a different user, configure Git to trust this repository directory globally:

git config --global --add safe.directory /usr/src/kodekloudrepos/media

If you face permission issues writing to the git repository configuration or directory, prefix your git commands with sudo (e.g., sudo git checkout master).


Step 4: Ensure You Are on the Master Branch

Switch to the base branch (master) before branching off, ensuring you have the latest baseline:

git checkout master

Verify your current active branch:

git branch

Expected output snippet:

* master

Step 5: Create and Switch to the New Branch

Create and switch to the new feature branch xfusioncorp_media using the checkout command:

git checkout -b xfusioncorp_media

Expected output snippet:

Switched to a new branch 'xfusioncorp_media'

Step 6: Verify Branch Creation

List all local branches to confirm that the new branch exists and is currently active (marked with an asterisk *):

git branch

Expected output snippet:

  master
* xfusioncorp_media

Post-Deployment Verification

Verify the branch status inside the repository:

git status

The output should confirm you are on the xfusioncorp_media branch with no commits or untracked changes:

On branch xfusioncorp_media
nothing to commit, working tree clean

Log out of the Storage Server to return to the Jump Host:

exit