In Kalatheme in Kalabox on Pantheon for a minute about time, we pulled down a Kalatheme based sub-theme into a recently installed Kalabox on our laptop, so we could run it locally and work on the project using Eclipse or any other IDE.
In this article we explore a simple but realistic Git-based workflow for Multidev and non-Multidev topic branches of a Pantheon dev project.
- Branches and environments
- Making changes and pushing back to a Multidev environment
- Coming into work and keeping your Multidev branch up-to-date
- Keeping your local Kalabox environment up-to-date
When you are going to make a change, make a branch.
When you are going to make a change, make a branch.
$ git status # On branch adevbranch nothing to commit (working directory clean) $ $ git checkout -b mytinycontribution … mess around … works well! ... $ git commit -am “My tiny contribution makes a big difference. Oh, and downloaded views” … $ git checkout adevbranch $ git merge mytinycontribution $ git push origin adevbranch
Now, an environment in Drupal is the actual running code. Meaning versioned code + database + files
The beauty of multidev on Pantheon, for example, is that you are given a full environment for each topic branch on your git workflow.
For more on branches, see References 1.2
For more on multidev, see References 2.5 and resources on Pantheon site.
We covered cloning a site into the Kalabox environment here.
So however you got it, you change directory into your newly cloned repo, do your changes, commit them, and push back.
$ cd multidevbranch $ git branch -a * master remotes/origin/HEAD -> origin/master remotes/origin/multidevbranch02 remotes/origin/master remotes/origin/master_before_restore_to_nnnnnnnn remotes/origin/multidevbranch $ git checkout multidevbranch Branch multidevbranch set up to track remote branch multidevbranch from origin. Switched to a new branch 'multidevbranch'
So now, conscious of the fact that you are not on “master” and not going to screw anything up, you make your changes, test them in your local environment, then if happy:
$ git commit -am “done it” $ git push origin multidevbranch
Now if you’re really getting confident, and someone has approved the fruit of your efforts, perhaps you’d like to actually merge into master (the Pantheon ‘dev’ environment):
$ git checkout master # switch to dev branch branch $ git pull origin master # did anyone else commit anything while I was working? If so fetch it and merge it into local master $ git merge origin/multidevbranch # merge in your stuff you just pushed to pantheon $ git push origin master # merge it into dev environment
At the risk of redundancy, here is what you do on any morning, actually; also works for after lunch, or getting home and wanting to do something after dinner:
$ cd multidevbranch $ git branch -a * master remotes/origin/HEAD -> origin/master remotes/origin/multidevbranch02 remotes/origin/master remotes/origin/master_before_restore_to_nnnnnnnn remotes/origin/multidevbranch $ git pull origin master $ git checkout multidevbranch $ git merge origin/master $ git push origin victorkane ## bring your multidev environment up-to-date!
Now that the local branch is up-to-date and useful into the bargain, what happens if others have added files, etc.? Got to keep your local environment up-to-date. For VPS or non-Kalabox situations, just download and untar and/or drush.
For Kalabox, we have terminatur (see References 4.1), a Kalamuna creation, included in the Kalabox setup.
To grab database and files from dev, then download to kalabox: 1. Go to multidevbranch Workflow 2. Clone from dev Environment (database and files and run update.php all checked) 3. Hit button "Clone the Database & Files from Dev..." 4. Use terminatur within Kalabox to refresh local environment with the database and files $ drush help pulldata Pulls down the database for a Pantheon site. Examples: drush pulldata sitename.dev Pulls down the database for a site at @terminatur.mysite.dev. Arguments: sitename The sitename.dev part of @terminatur.sitename.dev. $ drush help pullfiles Pulls down the files for a Pantheon site. Examples: drush pullfiles sitename.dev Pulls down the files for a site at @terminatur.mysite.dev. Arguments: sitename The sitename.dev part of @terminatur.sitename.dev. Options: --destination=</var/www/> The destination of your webroot. $ drush ta # refresh aliases usable by terminatur $ drush sa ... ... @terminatur.multidevbranch.dev @terminatur.multidevbranch02.dev @terminatur.multidevbranch02.dev So the sitename parameter will be: multidevbranch.dev And the commands will be: $ drush pullfiles multidevbranch.dev $ drush pulldata multidevbranch.dev $ drush cc all ## Did you remember to clear cache?
vagrant@kala:/var/www/multidevbranch$ drush pullfiles multidevbranch.dev
Downloading files... [warning]
Files downloaded. [success]
vagrant@kala:/var/www/multidevbranch$ drush pulldata multidevbranch.dev
How do you want to download your database?
 : Cancel
 : Get it from the latest Pantheon backup.
 : Create a new Pantheon backup and download it.
 : Pick one from a list of Pantheon backups.
Creating database backup... [warning]
Database backup complete! [success]
Downloading data... [warning]
Data downloaded. [success]
Video: http://www.youtube.com/watch?v=ed1EufMfAJQ (Jan 15 2014)
This Kalamuna article, Power to the People, explains that Kalabox is built upon a powerful Vagrant driven stack, Kalastack
This Kalamuna article, Ride the Hydra: Reduce Complexity, introduces the three goals for reducing Drupal workflow complexity:
Developers must use a standardized local development platform. (Kalabox)
Deployment (moving code between local, staging, and production environments) must be automated. (Pantheon)
Development must be transparent to site owners and team members alike. (Pantheon workflow, including branches coupled with complete environments (code+db+files), i.e. Multidev (My own take: Of course you can do “branching on the cheap” and just use Kalabox for that, or own VPS server; mix with additional GitHub remote!).
Kalastack on Github