DEV Community

Cover image for 2.Git Create Branches
Thu Kha Kyawe
Thu Kha Kyawe

Posted on

2.Git Create Branches

Lab Information

Nautilus developers are actively working on one of the project repositories, /usr/src/kodekloudrepos/media. Recently, they decided to implement some new features in the application, and they want to maintain those new changes in a separate branch. Below are the requirements that have been shared with the DevOps team:

On Storage server in Stratos DC create a new branch xfusioncorp_media from master branch in /usr/src/kodekloudrepos/media git repo.

Please do not try to make any changes in the code.
Enter fullscreen mode Exit fullscreen mode

Lab Solutions

Step-by-Step Instructions

  1. SSH into the Storage Server

From jump host (if required):

ssh natasha@ststor01.stratos.xfusioncorp.com
# password: Bl@kW
Enter fullscreen mode Exit fullscreen mode
  1. Go to the Git repository directory
cd /usr/src/kodekloudrepos/media
Enter fullscreen mode Exit fullscreen mode

Verify it is a git repo:

git status
Enter fullscreen mode Exit fullscreen mode

You should see something like:
To add an exception for this directory, call:

git config --global --add safe.directory /usr/src/kodekloudrepos/media
Enter fullscreen mode Exit fullscreen mode
  1. Ensure you are on the master branch

This is very important.

git branch
Enter fullscreen mode Exit fullscreen mode

If not, switch to master:

git checkout master
Enter fullscreen mode Exit fullscreen mode

Output

fatal: Unable to create '/usr/src/kodekloudrepos/media/.git/index.lock': Permission denied
Enter fullscreen mode Exit fullscreen mode

Change permission and checkout

sudo chown -R natasha:natasha /usr/src/kodekloudrepos/media
git checkout master
Enter fullscreen mode Exit fullscreen mode
  1. Create the new branch from master

Run ONLY this command:

git branch xfusioncorp_media
Enter fullscreen mode Exit fullscreen mode
  1. Verify the branch was created
git branch
Enter fullscreen mode Exit fullscreen mode

Resources & Next Steps
📦 Full Code Repository: KodeKloud Learning Labs
📖 More Deep Dives: Whispering Cloud Insights - Read other technical articles
💬 Join Discussion: DEV Community - Share your thoughts and questions
💼 Let's Connect: LinkedIn - I'd love to connect with you

Credits
• All labs are from: KodeKloud
• I sincerely appreciate your provision of these valuable resources.

Top comments (0)