DEV Community

Cover image for Git Branching Strategy Guide

Git Branching Strategy Guide

ak on June 06, 2024

As a developer since 2008, I’ve witnessed the evolution of version control systems firsthand. Starting with SVN and eventually transitioning to Git...
Collapse
 
nmiller15 profile image
Nolan Miller

In personal projects when I started I only used commits on the main branch. I’ve been continuously adding more complexity to my git workflow. Every time I add something it is so worth it. Might try this on my next project! Thanks for the direction!

Collapse
 
ak_23 profile image
ak

I'm glad you found it helpful! Adding structure to your git workflow can definitely enhance project management. Good luck with your next project!

Collapse
 
incrementis profile image
Akin C.

Hello Amit K,

thanks for your article.
I regularly use Git in combination with GitHub and your guide is very insightful.

The only thing I (and I bet many others) have concerns automated testing. If you ever have the time and desire to write something about this for beginners, I would love it.

Keep it up!

Collapse
 
ak_23 profile image
ak

Thank you for your kind words! I'm glad you found the guide insightful. Automated testing is indeed a crucial aspect of the development process. I'll definitely consider writing a beginner's guide on it in the future. Stay tuned, and happy coding!

Collapse
 
ptd profile image
Duc

I think the organization of this issue will depend on the structure and the number of members in the team. For example, my team is quite small, and we don't even use an intermediate branch. All branches like fixes/xxx, hotfixes/xxx, and features/xxx are based on the master branch. Once testing is completed, they can be merged directly into the master. Subsequent branches are responsible for merging the master branch to continue their work.

Collapse
 
ak_23 profile image
ak

Thank you for sharing your approach! Indeed, the branching strategy can vary based on team size and structure. Your streamlined method works well for smaller teams and ensures efficiency. It's always interesting to see different workflows in action!

Collapse
 
johnantony92 profile image
John Antony

Consider a scenario where multiple teams working together and each team has there own environment and each has separate delivery goals.That is T1 code has to go to production June 1st week but T2 goal is only on July and there is only one develop branch for the apis(there is no team wise develop branch every teams feature and bug fixes gets merged to same develop branch).Whats the ideal branching strategy in that scenario?

Collapse
 
toddbradley profile image
Todd Bradley

A lot of developers consider GitFlow to be outdated and poorly optimized for modern development shops. What are your thoughts about trunk based development?

Collapse
 
ak_23 profile image
ak

Thank you for your feedback! Trunk-based development is indeed gaining traction for its simplicity and speed. While GitFlow has its strengths, especially for controlled releases, many teams find TBD aligns better with modern CI/CD practices and reduces integration issues.

Collapse
 
elovelan profile image
Eric Loveland

Trunk-based dev with feature flags and no branches (outside of an occasional spike/prototype branch) has been a huge benefit for our teams. We no longer have to think about deployments since they can happen as soon as code is pushed and all we ever have to talk about is when we're ready to release a feature by turning its flag on!

Collapse
 
xephun profile image
X. Ephun

I've lost track of "git workflow" variations, but I do feel like "develop" branches are something I'm seeing less and less of lately. It would be interesting to do a statistical survey (wouldn't be hard to batch-scrape) from GitHub repositories to fit what recent trends in branch naming are.

Collapse
 
ak_23 profile image
ak

Thank you for your insight! A statistical survey on branch naming trends sounds fascinating and could provide valuable insights into evolving workflows.

Collapse
 
jayantbh profile image
Jayant Bhawal

This is indeed something that's followed in most companies that are bigger than maybe 100 devs or so.

While indie devs or smaller companies may not find too much of a benefit from this, as you work with more devs you'll definitely want structure wherever you can implement it.

Good stuff!

Collapse
 
rahulp772 profile image
Rahul Prajapati

Excellent! thank you for sharing such valuable information.
I have one question. suppose there are 10 developers working on different features and merging their branches into develop everytime. now we need to push only 2 features on main branch, it is feasible to make that new feature branch from develop branch? because develop branch contain all other modules.
I think we should create branch for new features from main branch only.

Collapse
 
ak_23 profile image
ak

Thank you for your kind words! You're correct; if you need to push only specific features to the main branch, creating a feature branch from the main branch is a good approach. This way, you can ensure the feature branch contains only the desired changes without other developments from the develop branch. This approach maintains a clean and controlled release process.

Collapse
 
beekrum profile image
Bikram Duwal

I think git cherry-pick will do the trick for picking some feature from develop branch to production (main) branch.

Collapse
 
ak_23 profile image
ak

Absolutely! Using git cherry-pick is a great way to selectively apply specific commits from the develop branch to the main branch. However, there will be potential risks like introducing conflicts or other issues.

Collapse
 
anshumansp profile image
Anshuman Parmar

Hello this is a sample text

Collapse
 
ak_23 profile image
ak

"Looks like this sample text skipped the develop branch and went straight to production!"

Collapse
 
softwaredeveloping profile image
FrontEndWebDeveloping

Great post Amit! Thanks.

Collapse
 
ak_23 profile image
ak

Thank you :)

Collapse
 
martinbaun profile image
Martin Baun

Excellent writeup Amit! I'm always down for Git :)

Collapse
 
ak_23 profile image
ak

Thank you! I'm glad you enjoyed it. Git is an invaluable tool for us developers!

Collapse
 
cagarraway profile image
cagarraway

Nice article. I will discuss this with my team.

Collapse
 
azurefilms profile image
Azurefilms

Great post ..!

Collapse
 
ak_23 profile image
ak

Thank you :)

Collapse
 
anshumansp profile image
Anshuman Parmar

H

Collapse
 
ak_23 profile image
ak

I

Some comments have been hidden by the post's author - find out more