I need some help with git branching strategy

I’m new to gitlab and I got assigned a task to create a gitlab environment with git branching strategy and gitlab CI/CD, I managed to deploy the gitlab instance and wrote a simple pipeline but I didn’t understand the part of git branching strategy?

I need some clarification?


git branching strategy doesn’t depend on GitLab. Branching models / strategies are general concepts that evolve around git and you can google around and find what suits best to your project’s use case. Most popular is perhaps GitFlow, but there are many others as well. It mostly depends on how are you going to handle your releases and eventually hotfixes.

The most simple branching strategy using GitLab would be like this:

  • you have a main branch which should always have stable code
  • developers make new feature branches from the latest main, commit and push to their branches
  • when developer’s feature is ready, he/she makes Merge Request (from his/her feature branch → main)
  • you trigger a pipeline on that MR, so you automatically build and test your code changes
  • other developers review code on that MR, and if needed, changes/adjustments are made (and pipeline re-runs with new changes)
  • finally, MR is approved and branch is merged into the main branch

Hope this gets clarifies a bit for a start :slight_smile:

1 Like