Hotfixes

For Experts only. You should not need to attempt this if you use Multidev and keep commits from reaching Dev that you do not intend on deploying.

Warning

We do not recommend hotfixing. Hotfixes should be the exception, not the norm. Pushing a hotfix via Git is the only way to push code directly to Live without having to go through Dev and Test. Hotfixing is not a best practice and any damage to the source code will be the responsibility of the user and should be avoided whenever possible.

Requirements

A working knowledge of Git tools.

An up-to-date clone of your Pantheon Git repository.

Get Into the Right Tag

From within your Git clone, get a quick list of the existing Git tags:

git checkout pantheon_live_1
Note: checking out 'pantheon_live_1'.
You are in 'detached HEAD' state. You can make experimental
changes and commit them, and you can discard any commits you make without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you can
do so by using -b with the checkout command again. Example:
git checkout -b new_branch_name
HEAD is now at ....</pre code>

You are now ready to start work based on the state of the live site.

Create new branch and start working:

git checkout -b hotfix
git commit -a -m "Hotfix issue xyz"

Generate a New Hotfix Test Tag

Make your hotfixes and commit them locally, then tag and push them to test by creating a new test tag with a higher number value:

Note

Your tag numbers will vary. We are showing 5 because in the list of tags above the highest number was 4. Be sure you have the right number before pushing.

Test and Deploy

Warning

Because we use caching on our Git logs, you may not see your hotfix commit listed in the test commit log. However, if you've pushed it up, you should be able to test your changes. Once you've verified that your code hotfix is there, you should pull the database back from Live to Test to be sure you're looking at a good test case before finally pulling it into the Live environment.

If your tests pass, you will need to repeat the process to deploy your changes to the Live environment. Currently, the deploys interface does not enable hotfix tags on test to be deployed directly to live.

Orphan Commits

On Pantheon an orphan commit is any commit that exists on the Test or Live environment, but not in the master branch.

Even when making hotfixes, your workflow should push those changes into the master branch. Since we have no way of knowing which future commit will contain those changes, we want you to be aware of potential code loss.

If you do want to preserve the orphan commits, follow these Git commands to make a clean merge:

Make sure to cherry-pick the commits in chronological order to avoid issues with your integration and replace the hash code in the example above with the actual hash of the commit you are trying to preserve.