How to use a scalable Git branching model called Gitflow

. How to use a scalable Git branching model called Gitflow

1. Throughout this series you've seen the number of branches that we use in order to manage our workflow growing. So to begin with, we started with a single branch called master and this is the branch that gets created when our repository is originally initialized, and we did all of our development on that branch. We even created a remote repository and cloned that repository in a production environment using just that branch, and we were all able to sync up code from our development site up to our production site and back again. Now, if you're a one-person team, this single branch model could be sufficient for you, but near the beginning of this series we explored using a feature branch in order to pull out our code into a separate branch and begin working on a feature making a series of commits to that feature before rolling it back into the master branch, the purpose of that being that we can create multiple feature branches and be able to polish our code on those features before pulling it into the main branch which will be pushed eventually to our production site.

2. Having our changes on that feature branch allows us to roll back simply by deleting the branch instead of having to roll back individual commits. So where this model starts to break down where we're using just a master and maybe some feature branches is when it comes to releasing to a production site that needs to be very stable; or maybe stability isn't a huge problem for you, but you have a larger team working together and so you need to make sure not to be stepping on each other's toes and breaking each other's development environments. In those situations, we need something a little bit more.

3. So one thing we did in the last video is we created a development branch and we made that the central branch where our development takes places, and then only when we are ready to release our code to our production site will we then push it straight to master. What this does is free us up a little bit to use that main development branch for actual development without having to worry too much about updating master and accidentally pulling in non-tested code. But there is still a couple of problems with that model, which is since we're using our development branch in order to push directly to production, that development branch could have some unmeasured features or some changes that we don't intend to push.

4. Also, it doesn't really give us a chance to test out our release code before we put it into production. In most website projects where stability is very important, where there is a large number of users or the types of users are very important to keep happy, then there will be a staging environment which is basically a duplicate of the production server where a new release is tested rigorously before that release then gets pushed to the production site. So a branching model that matches well with this model is to develop in the develop branch; and then at some point when you're ready for a release, you don't push directly to master, but instead you push to another branch called a release branch and that's the branch that you use on the staging server in order to test the release.

5. Now, as you find bugs and missing features on this release branch, you make fixes to that branch directly; and at the same time, there is still development going on in the development branch where people are adding new features and bug fixes that are going to be added to the next release. When the release is done being tested, it's then pushed to production and any changes that were made to this release are then merged back into the development branch in order to carry them forward to the next release. At that point, the release branch has had its life.

6. So then, what happens if we've pushed the release after we have tested it to the master branch, it's on production now and we find a bug? Well, this release is actually complete. We pushed it to master and we tagged it with a particular release version and we push those changes back to the development environment, and then we actually deleted this release branch because we are no longer going to make any modifications to it. Any bugs that we find that are now on the master branch are going to have to be fixed in a new release.

7. Now, some bugs are so important that they can't wait for the development branch to be ready for a new release. So a solution to this is to create another type of branch called the hotfix branch and what this does is it branches directly from master so it's got the same code base and then you make modifications to fix the bug, and then you merge it back with master, creating a new minor release of your software, of your application or website, and then you bring it back into development so that it's incorporated in the next release. Now, if you're new to version control and you are new to this whole concept of branching and merging, this is going to feel a little bit complex and a little bit overwhelming, and so it's totally okay for you to stick with a simple branching model using just the master branch, and experimenting a little bit with feature branches will get you a long way.

8. The rest of this setup though is a robust workflow that will work at any scale of project. So once you wrap your mind around it and maybe even employ it in your own projects, you're ready to work with a larger team; you're ready to work on projects that need great stability; and so it's a really good skill to have. Now, this whole branching model where there is master, develop, feature branches, release branches and hotfix branches is called Gitflow.

9. Now, a lot of the concepts in this model aren't really new, but they were brought together in this unique way to work with Git by a fellow named Vincent Driessen, and you can learn more about the model by going to nvie dot com slash posts a-successful-git-branching-model, and you see he's got some great diagrams here and he explains the purpose of each type of branch and what rules are associated with those branches. What's particularly excellent about this model is that even though it seems complex at first, this is really it. It's limited in its complexity.

10. Once you understand the purpose of each branch and integrate it in with your workflow, you really don't have to go any further than that when it comes to a branching-merging model. So in our next steps what we are going to do is talk through the creation of a release branch, a hotfix branch, and a feature branch and how to integrate those branches with a local development, a production and a team member's environment.
Change Management and Version Control

Learn how to use the Git version control system and explore how to use the Features module to capture everything in code. In this collection we also discuss using the Drush command line tool, as well as:

  • How to use the command line (even if you've never used it before)
  • How to build, deploy and update a feature module
  • How to use Git to build Drupal site scaffolding and extend Drush
Video Library
21m 46sIntroduction
21m1. Welcome to BuildAModule
10h 36mBuild Your First Drupal 7 Web Site
36m1. Introduction to Our Project and Reviewing Mockups
35m2. How to Create and Edit Content
38m3. How to Work With Menus, Modules and Webform
41m4. How to Work With Content Types and Fields
37m5. How to Work With Pathauto and Introduction to Views
32m6. How to Add Fields to a View and Work With the Date Module
36m7. How to Fix Broken Views and Work With Taxonomy
35m8. How to use Term and Node Reference Fields
31m9. How to Work With Blocks and Permissions
31m10. Overview of Permissions and Text Formats
34m11. Configuring Text Formats and Setting Up a Wysiwyg
33m12. Working With Custom Blocks and Image Styles
34m13. How to Work With CSS
34m14. Troubleshooting Module Installation and Configuration
33m15. Updating Modules and Manipulating CSS
32m16. More CSS Updates and Troubleshooting Text Formats
31m17. How to Evaluate Modules and Install IMCE
44m18. How to configure IMCE and Wrap Up Our Project
6h 18mAdvanced Site Building in Drupal 7
23m1. Welcome to Advanced Site Building
30m2. How to Set Up Administration Tools to Speed Up Productivity
36m3. How to Configure Content Type Settings and Splitting Fields Between Types
41m4. How to Use Display Suite for Grouping Fields and Positioning Content
14m5. How to Use the Context Module for Positioning Content
42m6. How to Use Panels for Positioning Content
48m7. How to Import Content With Feeds
48m8. Advanced Views
30m9. Where Display Modules Overlap and URL Strategy
28m10. How to Work With User Fields and Import Users
34m11. Formatting a Blog Entry Page
12h 48mPHP Programming Basics
25m1. Series Introduction and Your First PHP Script
45m2. Working With Strings and Variables in PHP
31m3. How to Work With Arrays in PHP
40m4. Logic, Control Structures and Looping
1h5. Creating Custom Functions and Working With External Data
22m6. Troubleshooting errors and using operators
1h7. Working With Forms in PHP
1h8. Working With Sessions in PHP
1h9. Working With the (MySQL) Database
1h10. Working with CRUD functionality and our database
2h11. How to Build Your Own Content Management System and Understand Drupal Better
1h12. Generalizing Functionality and Object Oriented Programming Primer
12h 23mDrupal 7 Development Core Concepts
22m1. Welcome to Module Building
35m2. How to Build Module Scaffolding
1h3. How Hooks Work and How to Use Them
26m4. Overview of Coding Standards
51m5. Development Tips and Tricks
1h6. How to Build and Manipulate Forms with the Form API
1h7. How to Add and Manipulate Pages With the Menu System
52m8. How to Add to and Manipulate the Theme Layer
1h9. How to Work With the Database
54m10. How to Work With Users
1h11. How to Work With Nodes
2h12. How to Work With JavaScript and jQuery
9h 25mChange Management and Version Control
49m1. Installing Git and Working on the Command Line
58m2. Staging, Committing and Undoing in Git
34m3. Branching, Merging and Tagging in Git
1h4. Working With Remote Git Repositories
38m5. Deploying Releases, Features, and Fixes With Git
24m6. How to Version Control the Database
1h7. How To Version Control Site Configuration With Features
25m8. How To Manage Non-Exportable Configuration Changes
57m9. How to Override Shared Features and Modify Text
33m10. How to Upgrade Drupal and Patch Contributed Modules
37m11. How to Install Drupal, Manage Features and Perform Common Tasks Using Drush
31m12. How to Configure Drush and use Drush Make
37m13. How to Extend Drush and Other Useful Drush Tools
8h 1mDrupal Theming Essentials
1h1. Important Drupal Theming Concepts
1h2. How to Build and Modify a Drupal Theme or Sub-Theme
1h3. How to Build and Modify a Drupal Theme or Sub-Theme, Part 2
54m4. Theme CSS File Structure and Extended Drupal Theme Building
1h5. Template Files, Theme Function Overrides and Preprocessing Functions
1h6. How to Work With Drupal Theme Settings
8h 55mDrupal 6 Development and Tools
3h1. Essential Concepts
27m2. Working with jQuery and Javascript
1h3. Securing a Module
58m4. Testing and Debugging a Module
1h5. PHP and MySQL Basics
1h6. Using Komodo Edit as an IDE
2h 17mWorking with Files and the File API
39m1. How to Work With Files and the File API
1h2. How to Work With Files and the File API, Part 2
22m 53sAppendix
22m1. Mentored Training Resources
Double-tap to return to library

Loading...