What is Gitflow and Why Should You Know About It?

What is Gitflow and Why Should You Know About It?

Daily short news for you
  • Since the Lunar New Year holiday has started, I won't be posting anymore. See you all after the holiday! 😁

    » Read more
  • Continuing about jj. I'm wondering if there are any GUI software made for it yet to make it easier to use. There are already so many similar to git that I can't count them all.

    Luckily, the author has compiled them all together in Community-built tools around Jujutsu 🥳

    » Read more
  • Turso announces that they are rewriting SQLite in Rust. This adds another piece of evidence supporting the notion that Rust is "redefining" many things.

    But the deeper reason is more interesting. Why are they doing this? Everyone knows that SQLite is open source, and anyone can create a fork to modify it as they wish. Does the Turso team dislike or distrust C—the language used to build SQLite?

    Let me share a bit of a story. Turso is a provider of database server services based on SQLite; they have made some customizations to a fork of SQLite to serve their purposes, calling it libSQL. They are "generous" in allowing the community to contribute freely.

    Returning to the point that SQLite is open source but not open contribution. There is only a small group of people behind the maintenance of this source code, and they do not accept pull requests from others. This means that any changes or features are created solely by this group. It seems that SQLite is very popular, but the community cannot do what they want, which is to contribute to its development.

    We know that most open source applications usually come with a "tests" directory that contains very strict tests. This makes collaboration in development much easier. If you want to modify or add a new feature, you first need to ensure that the changes pass all the tests. Many reports suggest that SQLite does not publicly share this testing suite. This inadvertently makes it difficult for those who want to modify the source code, as they are uncertain whether their new implementation is compatible with the existing features.

    tursodatabase/limbo is the project rewriting SQLite in Rust mentioned at the beginning of this article. They claim that it is fully compatible with SQLite and completely open source. Limbo is currently in the final stages of development. Let’s wait and see what the results will be in the future. For a detailed article, visit Introducing Limbo: A complete rewrite of SQLite in Rust.

    » Read more

The Problem

Since we often work with Git, it is safe to assume that most people are familiar with Git concepts such as branches and commands like checkout, merge, rebase, and revert.

When developing a new feature, we usually checkout from the current branch to another branch to work on it. In a team environment, multiple people may be developing multiple features, each on their own branch, allowing for independent and parallel development. Everything would be perfect if one day, when merging branches together, there were no conflicts.

Gitflow was created to define rules for branching and feature development, as well as product releases. It is a workflow for working with Git that is most convenient for developers.

What is Gitflow?

Gitflow is a concept that defines branching and coordination for developing and releasing features using Git.

Gitflow can be customized by development teams based on their environment and requirements. It can be either created from scratch or based on an existing workflow.

There are many variations of Gitflow, but the most famous one is based on Vincent Driessen's branching model.

Gitflow based on Vincent Driessen's Branching Model

gitflow Vincent Driessen

In Vincent Driessen's Gitflow, the workflow is as follows:

  • The starting branch is master. When starting development of a new feature, we checkout from master to develop.
  • Each feature is then checked out from develop to branches with the prefix feature/feature-name. For example, a login feature would be feature/login, and a logout feature would be feature/logout. Each feature is developed independently. After completion, the feature branch is merged into develop.
  • During the release cycle, develop is merged into release. The release branch acts as a staging environment for the project. It closely resembles the production environment and only includes bug fixes, not new features. If any bug fixes are needed on the release branch, they are merged back into develop.
  • When all bugs are fixed, the release branch is merged into master. A tag can be added to mark the release for convenient tracking and tracing.
  • In production, bugs are unavoidable. In such cases, we checkout from master to a hotfix/fix-name branch to fix the bug. After fixing the bug, the hotfix branch is merged into develop. Once the fix is verified in develop, it is merged into master, effectively ending the bug fix session.

As you can see, with this Gitflow model, we need at least three environments for running code: production, staging, and develop, corresponding to the master, release, and develop branches, respectively. However, in practice, it is not necessary to have all three environments. We can customize Gitflow to suit our project's needs and optimize it for efficiency.

The Gitflow based on Vincent Driessen's model can be complex and may slow down the development process or result in a high number of code conflicts. However, it provides clear and distinct branches, and it is easy to establish multiple environments (develop, staging, production).

For example, we can have just the develop and production environments but still ensure that feature development branches are checked out from develop and merged into master before going into production.

Apart from the flows mentioned above, there are other Gitflows as well. In fact, both GitHub and Gitlab have proposed Gitflows for working on their platforms. If time allows, I will write another article discussing the Gitflows proposed by these two industry giants.

Conclusion

In this article, I have presented the concept of Gitflow along with the Gitflow model based on Vincent Driessen's branching diagram. Gitflow was created to address the challenges of working in teams by providing a convenient and conflict-free workflow. Gitflow is also a characteristic of a software development team. If you are using any Gitflow, feel free to share it with others!

Premium
Hello

Me & the desire to "play with words"

Have you tried writing? And then failed or not satisfied? At 2coffee.dev we have had a hard time with writing. Don't be discouraged, because now we have a way to help you. Click to become a member now!

Have you tried writing? And then failed or not satisfied? At 2coffee.dev we have had a hard time with writing. Don't be discouraged, because now we have a way to help you. Click to become a member now!

View all

Subscribe to receive new article notifications

or
* The summary newsletter is sent every 1-2 weeks, cancel anytime.

Comments (1)

Leave a comment...
Avatar
Nguyễn Văn Nhật2 years ago
Gitflow trên khá rắc rối mà tôi làm ở các công ty thường sẽ có gitflow rút gọn hơn, vấn đề là việc áp dụng mô hình trên khá phức tạp và mọi người có xu hướng làm việc không nghiêm túc hay chỉ thời gian đầu
Reply
Avatar
Nguyễn Văn Nhật2 years ago
Đúng thế như cty mình flow tuỳ dự án bởi không phải maintain nhiều version cùng lúc
Avatar
Tùng Nguyễn2 years ago
Các cty thường sẽ rút ngắn luồng này xuống
Scroll or click to go to the next page