# Apply hotfix by using Git

In this article, you'll find a step-by-step guide on how to apply a hotfix to a Live environment using only Git.

* GitKraken

{% hint style="info" %}
You can use whichever Git client or command line interface you prefer.

If you've never worked with cherry-picking before, we recommend that using a Git client with visual overview of your commits.
{% endhint %}

## The scenario

You have an Umbraco Cloud project with two environments, Development and Live.

You have been working on building the site on a local clone of the Development environment. Now you want to send some but not all changes to the Live environment.

A set of commits have been pushed from your local clone to the Development environment. Out of these commits, you only need the changes from two of the commits in the Live environment for now.

![Commits](/files/E0tLmh611WD9lBO6dHXj)

## Apply selected changes to the Live environment

Here are the steps to follow to apply selected changes to the Live environment without deploying from Development to Live.

### Branching and Cherry-picking

1. Open your local clone of the Development repository in GitKraken (or your preferred Git client).
2. Make sure that the changes you push directly to your Live environment are already pushed to the Development environment. This will ensure that your environments are kept in sync.
3. Choose the commit where you want to create a new branch.
   * This branch should be created in an earlier commit that is corresponding to the state of the Live environment (before the changes you've made locally have been committed).

     ![Creating new branch](/files/s8mFuCFEAsF8rpNNOYP0)
4. With the new *Hotfix* branch checked out, it's now time to *cherry-pick* the commits you want to apply to the Live environment.
5. *Right-click* the commit you want and choose **"Cherrypick commit"**.
   * You will be asked if you want to commit this directly to the new branch - Choose **Yes**.
   * Choose **No** if you want to create a new message for the commit.
6. You can cherrypick as many commit as you like.
7. Your Git history will now look something like this.

   ![Cherrypicking](/files/m7OEsehomauKlJwV43h0)

### Push to Live

Before you push the newly created branch to Umbraco Cloud we need to change the *remote destination*. If you hit *Push* now, the branch would be pushed to the Development environment. You need to add the Live environment as a *new remote*.

1. Find the clone URL for the Live environment in the Umbraco Cloud Portal.

<figure><img src="/files/FT5tYUeOf4hjmb5foq6A" alt="Live Clone URL"><figcaption><p>Live Clone URL</p></figcaption></figure>

1. In GitKraken add a **new remote**, by clicking the **+** next to *Remote*.

   ![Add new remote](/files/SpBmNVeV0p1IyxFi8q88)
2. Give the new remote a name - like **Live**, and add the clone URL for the Live environment to both *Push URL* and *Pull URL* - click **Add Remote**.

   ![Add Live as remote](/files/9plHUIWUUbN5loyZd9Fe)
3. You will be prompted to authenticate - use your Umbraco Cloud credentials.
4. You will see that the history from the Live repository is visible in the Git history.
5. Click **Push**.
6. Choose to push to the newly added remote, and write `master` to make sure you are pushing to the master branch on the Live environment.

   ![Choose remote](/files/G2akt1eOelb4K5hg7zUi)
7. Hit **Submit** and the push will start.

{% hint style="info" %}
When changes are pushed directly to a Live environment and you have more than one environment, the changes are not automatically extracted into the site.
{% endhint %}

Find a guide on how to extract the files in the [Manual Extraction](/umbraco-cloud/optimize-and-maintain-your-site/monitor-and-troubleshoot/power-tools/manual-extractions.md) article.

You have now applied a hotfix to the Live environment. Make sure that you merge and remove the branch you've created on the Development repository before pushing it to the Development environment on Cloud. You can always create a new branch if you need to apply another hotfix to the Live environment.

When you are ready to build on your Development environment, follow the [normal workflow of the Cloud](/umbraco-cloud/build-and-customize-your-solution/handle-deployments-and-environments/deployment.md) to deploy the changes to the Live environment.

## Important notes

* This guide can also be used for applying a hotfix to a *Staging* environment.
* The above describes the workflow in GitKraken. You can use a git client of your choice or Git terminal/command prompt if you are comfortable with that.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.umbraco.com/umbraco-cloud/optimize-and-maintain-your-site/manage-product-upgrades/hotfixes/using-git.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
