What are GitLab Flow best practices?
GitLab Flow best practices help streamline software development using structured branching, continuous integration, and automated deployment techniques.
GitLab Flow best practices are guidelines for managing source code using GitLab’s version control, issue tracking, and CI/CD tools to ensure efficient, clean, and scalable development workflows. They include using feature branches, testing all commits early, automating deployments based on tags or branches, and maintaining clean commit histories.
When software development teams rush to accelerate delivery, they may end up with messy or complex workflows. Organizations that have transitioned from another version control system are especially likely to deal with challenging processes that may slow down development.
When teams use GitLab Flow, they can use feature driven development and feature branches with issue tracking to ensure every team member works efficiently. Using these GitLab Flow tips, software development teams can simplify the process and produce a more efficient and cleaner outcome.
Using feature branches is a simple way to develop and keep the source code clean. If a team has recently transitioned to Git from SVN, for example, they'll be used to a trunk-based workflow. When using Git, developers should create a branch for anything they're working on so that contributors can easily start the code review process before merging.
Some developers set up their CI to only test what has been merged into the main
branch, but this is too late in the software development lifecyle, and everyone - from developers to product managers - should feel confident that the main
branch always has green tests. It's inefficient for developers to have to test main
before they start developing new features.
When working on a feature
branch and adding new commits, run tests right away. If the tests are taking a long time, try running them in parallel. Do this server-side in merge requests, running the complete test suite. If there is a test suite for development and another only for new versions, it's worthwhile to set up [parallel] tests and run them all.
Don't test everything at the end of a week or project. Code reviews should take place as soon as possible, because developers are more likely to identify issues that could cause problems later in the lifecycle. Since they'll find problems earlier, they'll have an easier time creating solutions.
If developers don't want to deploy main
every time, they can create a production
branch. Rather than using a script or doing it manually, teams can use automation or have a specific branch that triggers a production deploy.
When pushing to a public branch, developers shouldn't rebase it, because that makes it difficult to identify the improvement and test results, while cherry picking. Sometimes this tip can be ignored when asking someone to squash and rebase at the end of a code review process to make something easier to revert. However, in general, the guideline is: Code should be clean, and history should be realistic.
After identifying a bug, a problematic action someone could take is fix it in the just-released version and not fix it in main
. To avoid it, developers should always fix forward by pushing the change in main
, then cherry-pick it into another patch-release
branch.
Developers should not only say what they did, but also why they did it. An even more useful tactic is to explain why this option was selected over others to help future contributors understand the development process. Writing descriptive commit messages is useful for code reviews and future development.
Discover how GitLab streamlines the code review process
Frequently Asked Questions
Frequently Asked Questions
The key practices include using feature branches rather than direct main commits, testing all commits immediately instead of only main branch, running complete test suites on every commit with parallel execution if needed, performing code reviews before merging, and automating deployments based on branches or tags. These practices ensure clean workflows and efficient development.
Teams should test all commits, not only ones on main branch, to ensure developers and product managers can trust that main always has green tests. Run every test on all commits, using parallel execution if tests take longer than 5 minutes. Execute complete test suites server-side in merge requests rather than waiting until the end.
Everyone should start from main and target main to prevent long branches. Developers check out main, build features, create merge requests, and target main again. Pushed commits should never be rebased to maintain clear improvement tracking and test results. History should be realistic while keeping code clean.
Fix bugs in main first and release branches second to avoid problems. Always fix forward by pushing changes to main, then cherry-pick into patch-release branches. Tags should be set by users rather than CI, and each tag should create a new release for clean, efficient development environments.
Commit messages should reflect intent by explaining not only what was done but why it was done. Even more useful is explaining why specific options were selected over alternatives to help future contributors understand the development process. Descriptive messages benefit code reviews and future development efforts.
Want to learn more about software development best practices?
50%+ of the Fortune 100 trust GitLab
Start shipping better software faster
See what your team can do with the intelligent
DevSecOps platform.