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 by using only Git.

    Tools used:

    • GitKraken

    You can use whichever Git client or cli you prefer.

    If you've never worked with cherry picking before, we recommend that you use a Git client with a UI that gives you a visual overview of your commits.

    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, and 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

    Apply selected changes to the Live environment

    Here are the steps to follow in order 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

    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 commits as you like.

    7. Your Git history will now look something like this.

      Cherrypicking

    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.

      Live Clone URL

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

      Add new remote

    3. 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

    4. You will be prompted to authenticate - use your Umbraco Cloud credentials.

    5. Now you will see that the history from the Live repository is visible in the Git history.

    6. Next step; hit Push.

    7. 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

    8. Hit Submit and the push will start.

    9. Note that 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.

    10. Find a guide on how to extract the files, in the Manual Extraction 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 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 building on your Development environment, follow the normal workflow of Cloud 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.