Managing Long-running Branches

Managing Long-running Branches

In software development, there are instances where creating a long-running branch when working on a project will be considered by developers. Long-running branches have been debated a lot by many teams due to their risks mainly around but not limited to, dare I say it, merge conflicts.

However, it isn’t necessarily the evil it’s made out to be and when handled with care, they can present extreme value to a team. Even DHH argues the benefits of maintaining a ‘cohesive architecture’ in this article opens a new window

First, let’s define what having a long-running branch actually means.

A long-running branch is a branch that is created with the expectation that it will remain open for the entirety of a project. Instead of being created, used, and then quickly merged back into the main branch, long-running branches stay active for an extended period as developers work on large features or significant changes. This could often be weeks or even months long. ​​These branches might undergo multiple updates, revisions, and code additions over time before they are finally merged into the main branch at the end of the project.

This presents an issue when the main branch is very active with many developers contributing and submitting changes at the same time.

At, we have used this workflow on many of our upgrade projects to avoid interruptions and maintain stability in the main branch. At the end of an upgrade, we will then work together with the client to merge the branch successfully into main to ensure continued stability.

So how do we maintain a long-running branch to avoid a complete disaster at the end?

Here are our best practice tips on how to manage a long-running branch during a project:

Keep the long-running branch as small as possible

When working on an upgrade project, there could be required updates that are also backward-compatible. These types of changes in a pull request can be merged into the main branch to maintain the integrity of a smaller long-running branch.

Dual Boot

If the project is an upgrade, dual boot both the main branch and long-running branch to help with the ability to merge in pull requests that have updates complying with newer Rails versions’ expectations. The next_rails opens a new window conditional availability in both branches will help maintain stability for the changes that apply.

Branch protection rules

Enforce branching protection rules using Github’s features and tools to prevent direct pushes to certain branches, apply code review requirements, and force status checks before merging. By enabling branch protection rules for long-running branches, you can ensure that changes undergo a thorough review and pass all necessary tests before being merged, reducing the risk of introducing bugs or breaking the build.

Topic Branches

Plan for a good pull request workflow by creating topic branches aka feature branches. This involves “a short-lived branch that you create and use for a particular feature or related work”. You can read more here opens a new window . This practice promotes collaboration, facilitates code review, and ensures that changes are thoroughly tested before merging.

Automated testing and Continuous Integration

Invest in adding automated testing and continuous integration (CI) to your GitHub workflow to further streamline the management of long-running branches. By setting up CI pipelines that automatically run tests whenever a new pull request is submitted or updated, you can catch issues early and prevent them from being potentially problematic in the main branch.


To prevent long-running branches from diverging too far from the main branch, it’s essential to regularly rebase and merge changes from the main branch into feature branches. This practice helps keep feature branches up-to-date with the latest changes, reduces the risk of merge conflicts, and makes the eventual merge into the main branch smoother and less error-prone.

Automated tools and scripts can assist with rebasing and merging, making the process more efficient and less error-prone.

Keep the long-running branch up-to-date with main

Frequently, and I mean very frequently, merging the main branch into the long-running branch can help mitigate a lot of the issues that most developers note when working on a long-running branch. This will ensure that your branch being worked on is consistent with the main branch avoiding as many conflicts as possible. This does not completely prevent merge conflicts in the future but can help with the cost of some.


Managing long-running branches doesn’t have to be a nightmare. By implementing some of the tips listed above, teams can streamline their development process, reduce risk, and deliver high-quality software more efficiently.

With the right tools and practices in place, you can utilize long-running branches and unlock the full potential of your development team. Need to get a project finished while your developers continue to work undisturbed? We can help, check out our services opens a new window and contact us today! opens a new window

Get the book