研发团队GIT开发流程新人学习指南

629次阅读  |  发布于3年以前

本文定位于为使用GIT标准分支开发流程的开发团队新人提供一份参考指南,其中的内容都是我们公司在研发团队初创时所遵循的一些开发流程标准,经过近一年的实践,虽说还有很多不足,但是随着团队经验的丰富和人员的扩张,我会适时地更新本文,分享我们在使用GIT开发流程中遇到的问题和解决方案。

本文将会持续修正和更新,最新内容请参考我的 GITHUB 上的 程序猿成长计划 项目,欢迎 Star,更多精彩内容请 follow me

分支流程说明

简介

项目中长期存在的两个分支

其它分支为短期分支,其完成功能开发之后需要删除

必读文章

团队中的 Git 实践
Git 在团队中的最佳实践--如何正确使用Git Flow

分支命令规范

特性(功能)分支

功能分支的分支名称应该为能够准确描述该功能的英文简要表述

feature/分支名称

例如,开发的功能为 新增商品到物料库,则可以创建名称为 feature/material-add的分支。

bug修复分支、紧急bug修复分支

bug修复分支的分支名称可以为Jira中bug代码或者是描述该bug的英文简称

bugfix/分支名称
hotfix/分支名称

比如,修复的bug在jira中代号为MATERIAL-1,则可以创建一个名为bugfix/MATERIAL-1的分支。

release分支

release分支为预发布分支,命名为本次发布的主要功能英文简称

release/分支名称

比如,本次上线物料库新增的功能,则分支名称可以为release/material-add

常用操作命令简介

基本操作

基本命令这里就不多说了,基本跟以前一样,唯一的区别是注意分支是从哪里拉去的以及分支的命名规范。涉及到的命令主要包含以下,大家自己学习:

分支操作参考 Git常用操作-分支管理

使用git flow简化操作

git flow是git的一个插件,可以极大程度的简化执行git标准分支流程的操作,可以在gitflow-avh安装。

如果是windows下通过安装包安装的git,则该插件默认已经包含,可以直接使用。

初始化

使用git flow init初始化项目

$ git flow init

Which branch should be used for bringing forth production releases?
   - develop
   - feature-fulltext
   - feature-vender
   - master
Branch name for production releases: [master]

Which branch should be used for integration of the "next release"?
   - develop
   - feature-fulltext
   - feature-vender
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? [/Users/mylxsw/codes/work/e-business-3.0/.git/hooks]

功能分支

git flow feature
git flow feature start <name>
git flow feature finish <name>
git flow feature delete <name>

git flow feature publish <name>
git flow feature track <name>

功能分支使用例子:

$ git flow feature start material-add
Switched to a new branch 'feature/material-add'

Summary of actions:
- A new branch 'feature/material-add' was created, based on 'develop'
- You are now on branch 'feature/material-add'

Now, start committing on your feature. When done, use:

     git flow feature finish material-add

$ git status
On branch feature/material-add
nothing to commit, working directory clean
$ git flow feature publish
Total 0 (delta 0), reused 0 (delta 0)
To http://dev.oss.yunsom.cn:801/yunsom/e-business-3.0.git
 * [new branch]      feature/material-add -> feature/material-add
Branch feature/material-add set up to track remote branch feature/material-add from origin.
Already on 'feature/material-add'
Your branch is up-to-date with 'origin/feature/material-add'.

Summary of actions:
- The remote branch 'feature/material-add' was created or updated
- The local branch 'feature/material-add' was configured to track the remote branch
- You are now on branch 'feature/material-add'

$ vim README.md
$ git add --all
$ git commit -m "modify readme file "
[feature/material-add 7235bd4] modify readme file
 1 file changed, 1 insertion(+), 2 deletions(-)
$ git push
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 303 bytes | 0 bytes/s, done.
Total 3 (delta 2), reused 0 (delta 0)
To http://dev.oss.yunsom.cn:801/yunsom/e-business-3.0.git
   0d4fb8f..7235bd4  feature/material-add -> feature/material-add
$ git flow feature finish
Switched to branch 'develop'
Your branch is up-to-date with 'origin/develop'.
Updating 0d4fb8f..7235bd4
Fast-forward
 README.md | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
To http://dev.oss.yunsom.cn:801/yunsom/e-business-3.0.git
 - [deleted]         feature/material-add
Deleted branch feature/material-add (was 7235bd4).

Summary of actions:
- The feature branch 'feature/material-add' was merged into 'develop'
- Feature branch 'feature/material-add' has been locally deleted; it has been remotely deleted from 'origin'
- You are now on branch 'develop'

$ git branch
* develop
  feature-fulltext
  feature-vender
  master

预发布分支

git flow release
git flow release start <release> [<base>]
git flow release finish <release>
git flow release delete <release>

hotfix分支

git flow hotfix
git flow hotfix start <release> [<base>]
git flow hotfix finish <release>
git flow hotfix delete <release>

git-flow 备忘清单

参考git-flow 备忘清单

总结

如果上面内容太多记不住,也没有关系,作为开发人员,刚开始的时候只要知道以下几点就足够了,其它的可以在碰到的时候再深入学习:

本文将会持续修正和更新,最新内容请参考我的 GITHUB 上的 程序猿成长计划 项目,欢迎 Star,更多精彩内容请 follow me

Copyright© 2013-2019

京ICP备2023019179号-2