# Git Cherry Pick

#### Git Cherry-Pick

* **Definition:** `git cherry-pick` applies changes from a specific commit to your current branch.
* **Summary:** Copies a single commit to another branch without merging the whole branch.
* **Use Case:** Pick select bug fixes or features from another branch without full merge.

### Tasks

1. Ensure you have access to the `storage server` where the repository is cloned at `/usr/src/kodekloudrepos`.
2. Navigate to the `/usr/src/kodekloudrepos` directory which contains the repository.
3. Identify the commit on the `feature` branch with the message `Update info.txt`.
4. Merge the identified commit from the `feature` branch into the `master` branch.
5. Push the updated `master` branch to the remote repository located at `/opt/official.git`.

### Steps

{% stepper %}
{% step %}
SSH into the storage server and get root

```bash
ssh natasha@ststor01
sudo su -
```

{% endstep %}

{% step %}
Navigate to the repo

```bash
cd /usr/src/kodekloudrepos/official
```

{% endstep %}

{% step %}
Fetch all branches to be sure you’re updated

```bash
git fetch --all
```

{% endstep %}

{% step %}
Check out the master branch&#x20;

```bash
git checkout master
```

{% endstep %}

{% step %}
Find the commit hash from feature branch with message "Update info.txt"

```bash
git log feature --grep="Update info.txt" --oneline
```

<figure><img src="https://3155059101-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Ftpxp8dhlubc3j58Iygn5%2Fuploads%2FL8E94rYxJ1jrY1gb4ENP%2Fimage.png?alt=media&#x26;token=f24885ab-a5b6-4be6-8ab2-de1a47e3f46f" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### git cherry-ping commit ha, 0e3895a

```bash
git cherry-pick 0e3895a
```

<figure><img src="https://3155059101-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Ftpxp8dhlubc3j58Iygn5%2Fuploads%2FcZRdoLEI6pqVb4RXhpX5%2Fimage.png?alt=media&#x26;token=2e29b6d4-4b28-47ba-8a68-88cdc237aa1f" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Push the updated master branch to remote

```bash
git push origin master
```

<figure><img src="https://3155059101-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Ftpxp8dhlubc3j58Iygn5%2Fuploads%2FWmOrYqtXmdJX5yUBj9oO%2Fimage.png?alt=media&#x26;token=a0387400-aefc-4e70-8462-b1e12ff40e22" alt=""><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}
