Git Flow

Git是一种非常强大的DVCS, 它的分支功能非常出色,有爱好者根据实际经验设计出一套基于分支的开发/发布模型, 原文见:http://nvie.com/posts/a-successful-git-branching-model/, 这个模型的概念如下图:

根据这个模型,Hacker们又开发出了一套基于这种模型的Git子模块, 名叫Git FLow. 它提供了一系列扩展命令,可以使开发者在自己的项目中方便的使用上文提到的开发模型.

安装

源码安装

$ git clone --recursive git: //github.com/nvie/gitflow.git
$ cd gitflow
$ [sudo] make install

安装补全模块

为了便于记忆与使用

$ git clone http: //github.com/bobthecow/git-flow-completion
$ cd git-flow-completion ; ls
git-flow-completion.bash
git-flow-completion.zsh
LICENSE
README.markdown
zsh : ~/.zshrc

在配置文件(~/.zshrc)中引入补全函数

...
source /path/to/git-flow-completion.zsh

使用方法

STEP1: 初始化gitflow仓库

$ git clone git@192.168.48.12:xxx.git
$ cd xxx

# 下载xxx旧版的develop分支到本地
master> git checkout -b develop origin/develop
Branch develop set up to track remote branch develop from origin.
Switched to a new branch 'develop'

# 初始化git flow 仓库, 一路默认即可
develop> git flow init                                                                                                                                                      /tmp/x/xxx

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

Which branch should be used for integration of the "next release"?
   - develop
Branch name for "next release" development: [develop]

How to name your supporting branch prefixes?
Feature branches? [feature/]
Release branches? [release/]
Hotfix branches? [hotfix/]
Support branches? [support/]
Version tag prefix? []

STEP2: 建立开发新功能的分支

$ git flow feature start SmsWidget
Switched to a new branch 'feature/SmsWidget'

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

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

     git flow feature finish SmsWidget

$ do some change
$ git commit -am "your comment"
...

STEP3: 功能开发完毕,结束该分支

feature/SmsWidget> git flow feature finish
Switched to branch 'develop'
Already up-to-date.
Deleted branch feature/SmsWidget (was 815ebd8).

Summary of actions:
- The feature branch 'feature/SmsWidget' was merged into 'develop'
- Feature branch 'feature/SmsWidget' has been removed
- You are now on branch 'develop'

如果你想在结束分支前Review你的改动

# 在feature分支下
feature/SmsWidget> git flow feature diff

如果多人共同开发新功能,你可以将该分支publish到中心仓库上

$ git flow feature publish feature/SmsWidget

参考

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值