当前位置: 首页 > 工具软件 > gitflow-avh > 使用案例 >

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

邢良才
2023-12-01

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
 类似资料: