1. 程式人生 > 其它 >GitFlow工作流記錄

GitFlow工作流記錄

工作流記錄

master分支和develop分支

基礎

The main branch stores the official release history, and the develop branch serves as an integration branch for features. It's also convenient to tag all commits in the main branch with a version number.

主分支用於正式釋出版本,使用版本號進行記錄,develop分支用於新功能的整合。

This branch will contain the complete history of the project, whereas main will contain an abridged version. Other developers should now clone the central repository and create a tracking branch for develop.

develop分支將包含專案的完整歷史記錄,其他開發人員修改bug或新增新功能時,應該從develop建立一個跟蹤分支,完成後合併到develop分支上,當功能都開發完成時,合併到master分支上進行釋出新版本。

release分支

Once develop has acquired enough features for a release (or a predetermined release date is approaching), you fork a release branch off of develop. Creating this branch starts the next release cycle, so no new features can be added after this point—only bug fixes, documentation generation, and other release-oriented tasks should go in this branch. Once it's ready to ship, the release branch gets merged into main and tagged with a version number. In addition, it should be merged back into develop, which may have progressed since the release was initiated.

一旦 develop 準備好了所有的新功能(或者預定的釋出日期臨近),就可以從 develop 分支遷出release分支。 (此時功能大致已經完成,建立relese用於修復剩餘Bug)
建立release分支會啟動下一個釋出週期,因此在此之後不能新增新功能——只有錯誤修復、文件生成和其他面向釋出的任務應該在此分支中進行。
準備好釋出後,release分支會合併到master分支中並帶有版本號標記。 此外,它應該重新合併到開發中,這可能自發布開始以來已經取得了進展。

Once the release is ready to ship, it will get merged it into main and develop, then the release branch will be deleted. It’s important to merge back into develop because critical updates may have been added to the release branch and they need to be accessible to new features. If your organization stresses code review, this would be an ideal place for a pull request.

release分支完成後,合併到master分支,之後release分支會被刪除,最後合併到develop分支也是很重要的。

Hotfix分支

Maintenance or “hotfix” branches are used to quickly patch production releases. Hotfix branches are a lot like release branches and feature branches except they're based on main instead of develop. This is the only branch that should fork directly off of main. As soon as the fix is complete, it should be merged into both main and develop (or the current release branch), and main should be tagged with an updated version number.
Having a dedicated line of development for bug fixes lets your team address issues without interrupting the rest of the workflow or waiting for the next release cycle. You can think of maintenance branches as ad hoc release branches that work directly with main. A hotfix branch can be created using the following methods:

修復版本用於快速修補釋出版本。一般是緊急修復。此分支是基於master分支,這是唯一一個可以直接合併到master分支的一種分支。修復完成後,應將其合併到master分支和develop分支(或當前release分支)中,並且master分支應使用更新的版本號進行標記。

例子

release 和 feature分支

git checkout main
git checkout -b develop
git checkout -b feature_branch
# work happens on feature branch
git checkout develop
git merge feature_branch
git checkout main
git merge develop
git branch -d feature_branch

hotfix分支

git checkout main
git checkout -b hotfix_branch
# work is done commits are added to the hotfix_branch
git checkout develop
git merge hotfix_branch
git checkout main
git merge hotfix_branch

總結

A develop branch is created from main
A release branch is created from develop
Feature branches are created from develop
When a feature is complete it is merged into the develop branch
When the release branch is done it is merged into develop and main
If an issue in main is detected a hotfix branch is created from main
Once the hotfix is complete it is merged to both develop and main