Skip to content

git flow

yangyp8110 edited this page Jan 17, 2018 · 1 revision

初始化项目

  • 初始化
$ git flow init

Which branch should be used for bringing forth production releases?
   - master
Branch name for production releases: [master]
Branch name for "next release" development: [develop]

How to name your supporting branch prefixes?
Feature branches? [feature/]
Bugfix branches? [bugfix/]
Release branches? [release/]
Hotfix branches? [hotfix/]
Support branches? [support/]
Version tag prefix? []
Hooks and filters directory? [D:/xxx/.git/hooks]
  • 查看所有分支
$ git branch -a

* develop
  master
  remotes/origin/HEAD -> origin/master
  remotes/origin/develop
  remotes/origin/master
  • 新拉一个feature分支
$ git flow feature start feature/feature_001
  • 修改完成,提交push后执行命令
$ git flow feature finish feature/feature_001
Your branch is up-to-date with 'origin/develop'.

git flow会自动合并feature/feature_001的更改到develop,并删除feature/feature_001分支

  • 创建release分支(先拉取develop,基于当前develop创建的)
$ git flow release start release/release_001
Branches 'develop' and 'origin/develop' have diverged.
  • finish release
$ git flow release finish release/release_001

此时会将release同时合并到develop和master分支,删除当前 release/release_001 分支,切换到develop分支

  • idel安装 git flow 插件

idel使用git flow开发

  • 单分支开发
    • 新建feature分支(基于develop),如:test_001分支
    • 开发完成后,commit 并 push分支,然后可以finish,finish后,回自动合并到develop并删除当前的feature分支(test_001)
    • 此时start一个release分支,会基于最新的develop新建一个release分支,可以基于当前分支做更改和测试
    • 测试完成后可以finish当前的release分支,此时会自动将release同时合并到develop和master分支(会自动记录tag并同时合并tag到develop和master,后续可以根据tag回滚代码)
  • 多分支&&多任务开发
    • 需求A新建feature分支taskA,还在开发中
    • 此时需求B比较紧急,需要优先于A上线,可以先commit分支taskA,push到远程taskA分支,重新开feature分支taskB
    • 完成后,可以先finish taskB,B需求先合并到develop,然后start release分支,finish release分支
    • B需求上线后,再切换到taskA,继续完成需求A,完成后,finish taskA,继续后续流程,更多feature参考前三步骤进行
Clone this wiki locally