# 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

{% stepper %}
{% step %}

### ssh storage server

```
ssh natasha@ststor01
```

{% endstep %}

{% step %}

### su access

```
sudo su -

```

{% endstep %}

{% step %}

### Navigate the given demo repo

```
cd /usr/src/kodekloudrepos/demo
```

<figure><img src="https://3155059101-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Ftpxp8dhlubc3j58Iygn5%2Fuploads%2FlEYCSoWKqTKihPTTZVNJ%2Fimage.png?alt=media&#x26;token=59e81dc5-e03b-49ee-9521-f42d2982fc7a" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Git status

```
git status
```

{% endstep %}

{% step %}

### Create new branch

```
git checkout -b nautilus
```

<figure><img src="https://3155059101-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Ftpxp8dhlubc3j58Iygn5%2Fuploads%2FIQzhX36Sb66GQHyIXtBA%2Fimage.png?alt=media&#x26;token=0abf2cca-5609-44e8-ab4a-ed726857fd40" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Again git status

```
git status
```

{% endstep %}

{% step %}

### Then, git branch

```
git branch
```

{% endstep %}

{% step %}

### Copy file

```bash
cp /tmp/index.html /usr/src/kodekloudrepos/demo/
```

<figure><img src="https://3155059101-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Ftpxp8dhlubc3j58Iygn5%2Fuploads%2FiapPZPZnMqEM9ZO0111h%2Fimage.png?alt=media&#x26;token=7fa334a7-ea03-441e-8ccc-494f2f3be847" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Commit and checkout to master

```bash
git commit -m "add index.html"
git checkout master
```

<figure><img src="https://3155059101-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Ftpxp8dhlubc3j58Iygn5%2Fuploads%2FIsDvDVFCtPLbd9IpIz5n%2Fimage.png?alt=media&#x26;token=0eba4139-501b-48b5-a043-04b38b4f7523" alt=""><figcaption><p>y</p></figcaption></figure>
{% endstep %}

{% step %}

### git merge

```
git merge nautilus
```

<figure><img src="https://3155059101-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Ftpxp8dhlubc3j58Iygn5%2Fuploads%2FQtIqF3LBNFeZsCY3CZWl%2Fimage.png?alt=media&#x26;token=36208e05-9817-4df1-849b-bfb7870e9acf" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
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.

<figure><img src="https://3155059101-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Ftpxp8dhlubc3j58Iygn5%2Fuploads%2FtM4QRf4NiVir70CxAVtk%2Fimage.png?alt=media&#x26;token=1542f438-9d2e-4c7b-bfff-5ab3e002f7e9" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Push to master now then git status

```
git push -u origin master
git status
```

{% endstep %}
{% endstepper %}
