Skip to main content

Trunk Based Git Workflow

At Figuro, we use a trunk-based Git workflow to ensure that our codebase stays stable, organized, and efficient. This approach allows us to maintain a single, continuously-evolving codebase, making it easier to collaborate, track changes, and deploy updates.

What is a Trunk Based Git Workflow?

In a trunk-based Git workflow, all code changes are made directly to the main branch (often referred to as trunk or master). This means that all development work happens in the same codebase, and there is only one version of the code that is in active development.

Developers create feature branches off of the main branch to work on new features or fixes. When the work is complete, they merge their feature branch back into the main branch, which triggers continuous integration and testing to ensure that the changes do not introduce bugs or conflicts with other code.

Why Do We Use a Trunk Based Git Workflow?

There are several benefits to using a trunk-based Git workflow:

  • Simplicity: With only one active codebase, developers do not have to worry about managing multiple branches or versions of the code. This streamlines the development process and reduces the risk of errors or conflicts.
  • Collaboration: By working on the same codebase, developers can easily collaborate and share knowledge with one another. This promotes a sense of teamwork and allows us to work more efficiently.
  • Continuous Integration: With every merge into the main branch, our codebase is tested and integrated automatically. This helps us catch issues early and avoid conflicts down the line.
  • Efficiency: Because there is only one codebase to manage, we can deploy updates more quickly and with less risk of errors or conflicts.

How We Use a Trunk Based Git Workflow

To implement a trunk-based Git workflow, we use GitHub as our primary code repository. We create a single, protected branch (usually named main or master) and require pull requests for all changes to this branch. We also require that all tests pass before any code can be merged into the main branch.

To help ensure that our code is of the highest quality, we use code reviews for all pull requests. This allows us to catch issues early and promote collaboration among team members.

We also use automation tools such as continuous integration and deployment (CI/CD) pipelines to automate testing, building, and deployment processes. This further streamlines our development process and ensures that we are always working with the latest, most stable version of the codebase.

We use Linear.app to track roadmaps, task and issues, GitHub Actions as CI/CD, and Vercel for deployment and previews.

Conclusion

At Figuro, we have found that a trunk-based Git workflow is an effective way to manage our codebase and ensure that our development process is as streamlined and efficient as possible. By using GitHub and implementing best practices such as code reviews and automation, we are able to maintain a stable, high-quality codebase that meets the needs of our customers.

Resources

If you want to learn more about trunk-based Git workflows and how to implement them, check out these resources: