Git Merge Branches

Tasks

  1. Navigate to the /usr/src/kodekloudrepos/demo repository.

  2. Create a new branch named nautilus from master.

  3. Copy the /tmp/index.html file into the repository.

  4. Add and commit the copied file to the nautilus branch.

  5. Merge the nautilus branch into the master branch.

  6. Push changes for both nautilus and master branches to the origin.

Steps

1

ssh storage server

ssh natasha@ststor01
2

su access

sudo su -
3
cd /usr/src/kodekloudrepos/demo
4

Git status

git status
5

Create new branch

git checkout -b nautilus
6

Again git status

git status
7

Then, git branch

git branch
8

Copy file

cp /tmp/index.html /usr/src/kodekloudrepos/demo/
9

Commit and checkout to master

git commit -m "add index.html"
git checkout master
y
10

git merge

git merge nautilus
11

Push the local nautilus branch to the remote origin with upstream tracking using:

git push -u origin nautilus

This sends commits to the remote repository, available for collaborators.

12

Push to master now then git status

git push -u origin master
git status

Last updated