So sánh git flow và git trunk based năm 2024
On a "mechanical" level, you seem to understand both version control strategies and their branching models. I believe there is a philosophical component that you are missing. Show The main philosophy with trunk-based development is to always have your main branch in a releasable state. This implies several things, some of which you already noted:
You can achieve 3 of the 5 items above using Gitflow. In my experience, merge conflicts happen more often simply because feature branches exist. Several lines of "in progress" work are built simultaneously, but not merged together. Long-lived branches are not mandatory in Gitflow. Branches tend to live longer in Gitflow simply because it is more permissible to create longer-lived branches. There is also a difference in what "feature branch" means. In Gitflow, a feature branch is longer lived because people tend to implement an entire user story or application feature. It is not uncommon for a developer to complete several tasks in a single feature branch. This takes longer, which is the reason why you get more merge conflicts. Feature branches in trunk-based development are used for tasks. Completing a story or application feature might require several tasks. Each task gets its own feature branch in trunk-based development. You likely need several feature branches to complete a story. You can emulate trunk-based development in Gitflow by using feature branches to complete 1 task, and merging everything into dev. This is an over-complication of trunk-based development, because the dev branch is yet another long-lived branch. Feature branches, the dev branch, release branches — they all serve to isolate work. The main difference between trunk-based development and Gitflow is how each isolates different lines of in-progress work. Gitflow achieves isolation of work using version control. New features are isolated in their own branches. Trunk-based development achieves isolation of work using feature toggles and other coding practices rather than how the team uses version control. This article was written by Scott Fitzpatrick, who has years of experience as a software developer. He has worked with many languages, including Java, ColdFusion, HTML/CSS, JavaScript and SQL. Scott is a regular contributor at Fixate IO. The right branching model will improve any team’s collaboration, quality, and speed. The wrong model will do exactly the opposite. These are the 3 most used branching models. Name a company that develops software, there’s a very high chance they’re are using Git to source control their codebase. Actually, there’s a 77% chance, according to Smartbear’s State of Code Review 2020 Report. There’s also a very high chance this company has a code review process in place. An 84% chance according to Codegrip’s Code Review Trends in 2020 report. However, there isn’t a single standardized methodology to develop software using Git and Code Reviews because it’s highly dependent on the team and the project characteristics. It’s entirely up to the team to choose which methodology better suits their software development needs and goals. We’ll go over the 3 main methodologies (also called branching models or branching strategies):
The original: Git FlowRarely a blog post has such an impact in the industry as the one Vincent Driessen published on January 05, 2010, named A successful Git branching model. In his post, Driessen laid out Git Flow, a robust and strict branching model that became the industry standard for software development for years. It brought parallel development to the masses, created the perfect conditions for collaborative programming, and it scaled easily. With it, many companies managed to grow large and efficient teams and to deploy very complex software. With Git Flow, the repository is centered on the Code Reviews play an essential part in ensuring the code is up to standard and bug-free when merging Git Flow allows for a very methodic and orchestrated software development but comes at a very high cost:
The successor: GitHub FlowWith the advent of web apps and continuous delivery, a lighter and faster branching model gained traction: GitHub Flow. As you might’ve guessed, it was created and popularized by the very own GitHub. It’s centered on the Compared to Git Flow, GitHub Flow is much lighter. Maintenance is very low because the only long-lived branch is However, GitHub Flow inherits other drawbacks from Git Flow. Undisciplined teams that keep The shift: Trunk-Based DevelopmentAlso going by TBD, Trunk-Based Development is somewhat famously documented at trunkbaseddevelopment.com. In this branching model, developers make changes directly in a single branch called `develop`7. `develop`8 is deployable at all times. Changes should be summited daily. Unfinished features should be unexposed with the help of feature flags. Yes, you read it right. It sounds like Yolo Software Development. There are is no code review in TBD, either. The catch is that this method can only work in small teams, with seasoned developers, and pair-programming is highly recommended. The pace is very fast because there is very little, if any, overhead. The team must be very skilled and cautious because everything goes directly to the `develop`7. This TBD model is actually officially called Trunk-Based Development For Smaller Teams. Despite its shortcomings, TBD for Smaller Teams is highly regarded by the software development community for its extremely lightweight workflow. The seasoned: Scaled Trunk-Based DevelopmentLuckily TBD has another trick up its sleeve: Scaled Trunk-Based Development. In order to operate at scale, this branching model uses short-lived Work in progress should be kept to a minimum, not only to avoid merging problems with long-lived Code reviews will guarantee only quality code is merged to the `develop`7 and will allow for very early defect detection. With Scale TBD, continuous integration is guaranteed, parallel development is supported, and quality is ensured with simple code reviews. It allows for quicker iterations with fewer errors, and it’s always deployable with very little branch management. Own it!It goes without saying that each team and/or product might warrant different needs in a branching model. Teams should take extra care choosing one. Whichever branching model is chosen, it is very (!) important that it’s crystal clear to every team member what are the rules and steps in the workflow. Without it, any model will fail to bring out the best of the team and the product. |