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.
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.
Note that Integrated Composer is not compatible with the hotfix workflow.
- A working knowledge of Git tools.
- An up-to-date clone of your Pantheon Git repository.
- A site that does not use Integrated Composer.
Navigate to your Git clone and run the command below to get a list of the existing Git tags:
git tag pantheon.initialize pantheon_live_1 pantheon_test_1 pantheon_test_2 pantheon_test_3 pantheon_test_4
To get only the highest
livetag, use the following:
git tag | grep pantheon_live_ | sort -k1.15n | tail -1
Select the highest
livetag and check it out:
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. ...
You are now ready to start work based on the state of the live site.
Create a new branch and start working:
git checkout -b hotfix git commit -a -m "Hotfix issue xyz"
Make your hotfixes and commit them locally. Once you're done, find the latest tag deployed to test:
git tag | grep pantheon_test_ | sort -k1.15n | tail -1
Tag and push them to test by creating a new test tag with a higher number value:
git tag -a pantheon_test_5 -m "Preparing a hotfix" git push origin pantheon_test_5Info: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. The commands above should tell you the appropriate tag number.
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. After you've verified that your code hotfix is there, 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.
You will see a message that there is a pending change that needs to be deployed if your tests pass.
Open Deploys and click the Live tab to see changes pending deployment.
_new_tag to deploy changes to Live:
git tag -a pantheon_live_2 -m "Deploying my hotfix" git push origin pantheon_live_2
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:
git checkout master git checkout -b hotfix git cherry-pick 0f230b0ef9fdce5d794cb1a4b6cf26a8052ba92a git checkout master git merge hotfix
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.