DEV Community

Cover image for 3.Git Merge Branches
Thu Kha Kyawe
Thu Kha Kyawe

Posted on

3.Git Merge Branches

Lab Information

The Nautilus application development team has been working on a project repository /opt/games.git. This repo is cloned at /usr/src/kodekloudrepos on storage server in Stratos DC. They recently shared the following requirements with DevOps team:

Create a new branch nautilus in /usr/src/kodekloudrepos/games repo from master and copy the /tmp/index.html file (present on storage server itself) into the repo. Further, add/commit this file in the new branch and merge back that branch into master branch. Finally, push the changes to the origin for both of the branches.

Lab Solutions

Step-by-Step Solution

  1. Login to Storage Server
ssh natasha@ststor01.stratos.xfusioncorp.com
# Password when prompted: Bl@kW
Enter fullscreen mode Exit fullscreen mode
  1. Switch to root
sudo su -
# Password when prompted: Bl@kW
Enter fullscreen mode Exit fullscreen mode
  1. Go to the repository
cd /usr/src/kodekloudrepos/games
# Verify:
git status
Enter fullscreen mode Exit fullscreen mode
  1. Create and switch to new branch nautilus
git checkout -b nautilus
# Verify:
git branch
Enter fullscreen mode Exit fullscreen mode
  1. Copy the file into the repo
cp /tmp/index.html .
# Verify:
ls
Enter fullscreen mode Exit fullscreen mode
  1. Stage and commit
git add index.html
git commit -m "Add index.html file"
Enter fullscreen mode Exit fullscreen mode
  1. Switch back to master and merge
git checkout master
git merge nautilus
Enter fullscreen mode Exit fullscreen mode
  1. Push BOTH branches
git push -u origin nautilus
git push -u origin master
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)