One, the master branch Master
The code base should have one and only one master branch: master . All official versions provided to users are released on this master branch.
tag
for each release, such as tag v1.0.0、tag v2.0.0
Two, the development branch Develop
main branch only used to distribute major versions, and daily development should be completed on another branch. We call the development branch develop .
This branch can be used to generate the latest overnight version of the code (nightly). If you want to officially release it to the outside world, you can "merge" the develop master branch merge ).
The Git command to create the Develop branch:
git checkout -b develop master
The command to publish the Develop branch to the Master branch:
# 切换到Master分支 git checkout master # 对Develop分支进行合并 git merge --no-ff develop
== Here is a little explanation, what is the meaning
--no-ff
By default, Git performs a "fast-forward merge" (fast-farward merge
), which will directly point the Master branch to the Develop branch. ==After using the
--no-ff
parameter, a normal merge will be performed and a new node will be generated on the Master branch. In order to ensure the clarity of the version evolution, we hope to adopt this approach.
Three, temporary branch
The two main branches of the repository: master and d evelop . The former is used for official release, and the latter is used for daily development.
In fact, the permanent branch only needs these two items, and no other items are needed.
However, in addition to the permanent branches, there are also temporary branches for version development for specific purposes. There are three main types of temporary branches:
- `Feature ( feature ) branch
- Pre-release ( release ) branch
- Fix the bug ( fixbug ) branch
These three branches are temporary needs, and should be deleted after use, so that the permanent branches of the code base are always only Master and Develop.
==Next, let's look at these three kinds of "temporary branches" one by one. ==
3.1 feature branch-feature
feature branch , it is for the development of a specific function, Develop branch. After the development is completed, it must be merged into Develop.
The name of the feature branch can be named in the form of feature-
# 创建一个功能分支: git checkout -b feature-开发一个新功能 develop # 开发完成后,将功能分支合并到develop分支: git checkout develop git merge --no-ff feature-开发一个新功能 # 删除feature分支: git branch -d feature-开发一个新功能
3.2 Pre-release branch -release
pre-release branch , it refers to the release of the official version (that is, before merging into the Master branch), we may need to have a pre-release version for testing.
pre-release branch is separated from the Develop branch. After the pre-release is over, it must be ==
merged into the Develop and Master branches ==. Its name can be used release- form of *.
# 创建一个预发布分支: git checkout -b release-1.2.0 develop # 确认没有问题后,合并到master分支: git checkout master git merge --no-ff release-1.2.0 # 对合并生成的新节点,做一个标签 git tag -a 1.2 # 再合并到develop分支: git checkout develop git merge --no-ff release-1.2.0 # 最后,删除预发布分支: git branch -d release-1.2.0
3.3 Fix the bug branch-fixbug
The last one is to patch the bug branch. After the software is officially released, bugs will inevitably occur. At this time, you need to create a branch for bug fixes.
The bug fix branch is ==
is branched from the Master branch ==. After the repair is over, then ==
merged into the Master and Develop branches ==. It can be named in the form of fixbug-
创建一个修补bug分支: git checkout -b fixbug-0.1 master 修补结束后,合并到master分支: git checkout master git merge --no-ff fixbug-0.1 git tag -a 0.1.1 再合并到develop分支: git checkout develop git merge --no-ff fixbug-0.1 最后,删除"修补bug分支": git branch -d fixbug-0.1
I am Xiaoyue, focusing on sharing advanced skills and technical dry goods in the front-end field! More dry goods in the public number: a journey of advanced front-end
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。