Trunk Based Development

Advanced Git

Amanda Crawford-Adamo

Software and Data Engineer

What is Trunk Based Development?

  • Source control branching CI/CD model
  • Developer no longer push to separate release branches
  • Changes are from short-lived branches pushed to main
  • Small and frequent updates

A graph of commits to main branch and showing branch as release trunk

Advanced Git

Core principles of Trunk Based Development

  1. Frequent commits to main
  2. Short-lived feature branches (< 1 day)
  3. Continuous integration
  4. Feature flags for incomplete work

A depiction of trunk based workflow. Short lived branch includes a feature flag toggle when committing to main.

Advanced Git

Feature flagging in TBD

  • Manages incomplete features
  • Prevent user from being affected
  • Features gradually released

Example Feature Flag Code

  if feature_flag_enabled('new_feature'):
      # New feature code
  else:
      # Old feature code
Advanced Git

Continuous integration in TBD

  • Commits to main trigger automated build and tests
  • Reduce maintenance and faster releases
  • Product alway reliable and stable
  • Ensure secure code and compliance with industry standards
  • Maintain code quality and reduce bug risk
Advanced Git

Benefits and challenges of TBD

Benefits:

  • Reduced merge conflicts
  • Faster release cycles
  • Improved code quality
  • Better collaboration

Challenges:

  • Requires team discipline
  • Needs robust testing
  • Initial learning curve
  • Managing incomplete features
Advanced Git

Best Practices

  1. Commit small changes frequently
  2. Automate testing and deployment
  3. Use feature flags for incomplete work
  4. Conduct regular code reviews
  5. Monitor after deployment
Advanced Git

Let's practice!

Advanced Git

Preparing Video For Download...