Git Flow使用

git flow使用流程

文章目录

    • 1. 安装git flow
    • 2. 初始化
    • 3. 开发新功能
      • 3.1 多人协作需要提交分支
    • 4. 开发完成,删除分支

1. 安装git flow

windows: 提前安装好 wget 和 util-linux

 wget -q -O - --no-check-certificate https://raw.github.com/petervanderdoes/gitflow-avh/develop/contrib/gitflow-installer.sh install stable | bash

linux: apt-get install git-flow
mac: brew install git-flow-avh一般默认自带

2. 初始化

对已有项目进行git flow 初始化

到项目目录下执行命令:
前置条件需要, 本地需要有master分支和develop分支, 没有就使用下面两条命令进行创建分支
git checkout -b master origin/master
git checkout -b develop origin/develop
使用初始化命令:git flow init
如果不小心填错, 就使用 git flow init -f 重新再来一遍

Ξ projects/leilanyu git:(develop) ▶ git flow init

Which branch should be used for bringing forth production releases?
   - develop
   - master
# 选择你的产品分支
Branch name for production releases: [develop] master

Which branch should be used for integration of the "next release"?
   - develop
 # 选择你的下一个版本的开发分支
Branch name for "next release" development: [develop] 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/zhan/bachang/cr/.git/hooks] 
Ξ projects/leilanyu git:(develop) ▶ 

3. 开发新功能

在项目目录下面使用命令:git flow feature start you_new_feature
该命令会以 刚才选的的develop分支为基础创建一个新的分支

Ξ projects/leilanyu git:(develop) ▶ git flow feature start my_train
Switched to a new branch 'feature/my_train'

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

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

     git flow feature finish my_train

Ξ projects/leilanyu git:(feature/my_train) ▶ 

3.1 多人协作需要提交分支

如果是多人协作需要提交你刚刚创建的 feature/my_train分支到远程分支 git flow feature publish my_train
然后使用普通git命令进行合并更新分支内容

4. 开发完成,删除分支

git flow feature finish my_train

你可能感兴趣的:(git)