使用gitflow完成新分支的创建和代码的提交

1.首先安装gitflow
作者本人电脑配置为windows环境,使用如下命令:

 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、初始化:
对于已经存在的项目

到项目目录下执行命令:
前置条件需要, 本地需要有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.使用gitflow创建一个新的分支:
在项目目录下面使用命令: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)

4.代码编写完成之后,提交并合并分支:
如果是多人协作需要提交你刚刚创建的 feature/my_train分支到远程分支 git flow feature publish my_train
然后使用普通git命令进行合并更新分支内容

5.删除分支:使用结束命令,自动完成分支的合并和删除:

git flow feature finish my_train
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值