工作生活

介绍Git flow规范

2019-07-03  本文已影响0人  YJ_Wong

Git Flow流程图


image.png image.png

所有的项目都会有三个分支

image.png

发版前

所以每当有新代码被merge到master后,就意味着一个新的版本已经生成,下一步一定是发布。否则可能会出现的问题:某个代码已经merge到master上了,但没发布。其余功能全上了后,发现有一个相关功能出现问题。
建议使用自动发布脚本来完成这一系列的操作,避免人为操作的影响造成漏洞。

其他分支:

除了master和develop分支外,还需要其他的分支来支持日常开发以及对应的紧急修复等更复杂的情况。但这些分支都有一个共同的特性:他们都只有有限的生命周期,不像master或develop一样是永驻的。
大致分为以下几类:
Feature branches
Hotfix branches
Release branches
这些分支都有一个特定的目的,同时也有严格的merge规则。

Feature branches

特性分支(有时称为主题分支)用于为即将发布的或遥远的将来的版本开发新特性。当开始一个特性的开发时,包含这个特性的目标发行版很可能还不知道。特性分支的本质是,只要特性还在开发中,它就会存在,但是最终会被合并回develop中,或者被丢弃。

Feature作为开发者管理自身的功能点的迭代,一般不需要推向origin。

$ git checkout -b feature/article
image.png image.png

规则:feature分支只能mergin到develop分支。

Finish feature

image.png

feature完成后需要删除该分支。

$ git checkout develop

$ git merge --no-ff myfeature

$ git branch -d myfeature

$ git push origin develop

--no-ff

image.png

--no-ff的作用是在merge分支的同时,把原先分支的提交记录一并合并到develop分支上。如果只是执行默认merge,则只会生成一条
Merge branch xxx of xxxx.com into xxx

Hotfix branches

image.png
image.png

提交规范

日常提交分为以下几种
feat: A new feature
fix: A bug fix
docs: Documentation-only changes
style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
refactor: A code change that neither fixes a bug nor adds a feature
perf: A code change that improves performance
test: Adding missing tests
chore: Changes to the build process or auxiliary tools and libraries such as documentation generation
deps: Updates about dependencies

建议团队内引进
feat:
fix:
refactor:
deps:

上一篇 下一篇

猜你喜欢

热点阅读