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
  • Privacy Guides is a non-profit project aimed at providing users with insights into privacy rights, while also recommending best practices or tools to help reclaim privacy in the world of the Internet.

    There are many great articles here, and I will take the example of three concepts that are often confused or misrepresented: Privacy, Security, and Anonymity. While many people who oppose privacy argue that a person does not need privacy if they have 'nothing to hide.' 'This is a dangerous misconception, as it creates the impression that those who demand privacy must be deviant, criminal, or wrongdoers.' - Why Privacy Matters.

    » Read more
  • There is a wonderful place to learn, or if you're stuck in the thought that there's nothing left to learn, then the comments over at Hacker News are just for you.

    Y Combinator - the company behind Hacker News focuses on venture capital investments for startups in Silicon Valley, so it’s no surprise that there are many brilliant minds commenting here. But their casual discussions provide us with keywords that can open up many new insights.

    Don't believe it? Just scroll a bit, click on a post that matches your interests, check out the comments, and don’t forget to grab a cup of coffee next to you ☕️

    » Read more
  • Just got played by my buddy Turso. The server suddenly crashed, and checking the logs revealed a lot of errors:

    Operation was blocked LibsqlError: PROXY_ERROR: error executing a request on the primary

    Suspicious, I went to the Turso admin panel and saw the statistics showing that I had executed over 500 million write commands!? At that moment, I was like, "What the heck? Am I being DDoSed? But there's no way I could have written 500 million."

    Turso offers users free monthly limits of 1 billion read requests and 25 million write requests, yet I had written over 500 million. Does that seem unreasonable to everyone? 😆. But the server was down, and should I really spend money to get it back online? Roughly calculating, 500M would cost about $500.

    After that, I went to the Discord channel seeking help, and very quickly someone came in to assist me, and just a few minutes later they informed me that the error was on their side and had restored the service for me. Truly, in the midst of misfortune, there’s good fortune; what I love most about this service is the quick support like this 🙏

    » 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

The secret stack of Blog

As a developer, are you curious about the technology secrets or the technical debts of this blog? All secrets will be revealed in the article below. What are you waiting for, click now!

As a developer, are you curious about the technology secrets or the technical debts of this blog? All secrets will be revealed in the article below. What are you waiting for, click 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