# Git Stash

### Tasks

1. Go to the Git repository located at `/usr/src/kodekloudrepos/blog` on the Storage server.
2. Identify available stashes.
3. Apply the stashed changes with the identifier `stash@{1}`.
4. Commit the restored changes with an appropriate message.
5. Push the changes to the `origin` remote.

### Steps

{% stepper %}
{% step %}
**SSH to storage server and switch to root if needed**

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

{% endstep %}

{% step %}

### Navigate to blog directory

```bash
cd /usr/src/kodekloudrepos/blog
```

{% endstep %}

{% step %}
Confirm `stash@{1}` exists

```bash
git stash list
```

<figure><img src="https://3155059101-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Ftpxp8dhlubc3j58Iygn5%2Fuploads%2FQayhGgueadRH5VVNflqy%2Fimage.png?alt=media&#x26;token=6b5e1bff-3c89-4ecd-99f8-e6f0ae75d06a" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Restore the stashed changes

```bash
git stash apply stash@{1}
```

<figure><img src="https://3155059101-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Ftpxp8dhlubc3j58Iygn5%2Fuploads%2FKm05fjksv2nI6OoXabrd%2Fimage.png?alt=media&#x26;token=b9e24336-eeef-46f9-a299-e7abfe1b696f" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Confirm restored files are ready for commit

```bash
git status
```

<figure><img src="https://3155059101-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Ftpxp8dhlubc3j58Iygn5%2Fuploads%2FWKQ6NkReV8NHvn74Adl9%2Fimage.png?alt=media&#x26;token=a6fa05f1-8ef3-45e2-891d-8b5c2db5d4c9" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Git add and commit

```bash
git add .
git commit -m "Restore changes from stash@{1}"
```

{% endstep %}

{% step %}
Push to remote

```
git push origin master
```

<figure><img src="https://3155059101-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Ftpxp8dhlubc3j58Iygn5%2Fuploads%2FdgHXuyO2EB7Lpho1AXo4%2Fimage.png?alt=media&#x26;token=aa00e158-bc76-420b-99d4-36248d737326" alt=""><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}
