• 使用git-flow来帮助管理git代码


    对git不熟悉的我,经常把git提交搞得很乱,导致在master上有许多无用的commit,最终决定好好地看一下git的使用教程,却不小心发现了还有一个git-flow的工具可以帮助我管理好git项目的代码。

    git-flow在ubuntu上使用比较简单。首先安装,可以通过apt-get来获取。命令如下:

    sudo apt-get install git-flow

    如果是在windows下,可以参考这篇文章进行安装:http://my.eoe.cn/sunxun/archive/158.html

    如果你的git已经装好,则方便多了,下载下面两个地址的文件,并解压出getopt.exe和libintl3.dll放到git的安装目录的bin目录下。

    http://sourceforge.net/projects/gnuwin32/files/util-linux/2.14.1/util-linux-ng-2.14.1-bin.zip/download

    http://sourceforge.net/projects/gnuwin32/files/util-linux/2.14.1/util-linux-ng-2.14.1-dep.zip/download

    然后检出github上gitflow项目,如下命令:

    git clone --recursive git://github.com/nvie/gitflow.git

    进入并执行里面的contrib\msysgit-install.cmd, 提示复制成功,就可以了。

    接下来是初始化项目。我在我原来的git项目上执行以下命令来进行初始化:

    git flow init


    它会创建或转换一个新的版本分支结构,当然在初始化的过程中,会问到以下这边问题,我都选择了默认:

    Which branch should be used for bringing forth production releases?
       - master
    Branch name for production releases: [master]
    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? []
    


    完成之后,通过git branch 命令,可以看到它为我们新建好了一个develop的分支。

    接下来我将继续使用,这篇笔记再慢慢补充。

    修复一个bug。

    git flow hotfix start 3

    它会创建一个基于master的分支hotfix/3,并切换到当前分支。

    当修复完成后,可以执行以下命令:

    git flow notfix finish 3

    增加一个功能特性

    git flow feature start demo

    它会创建一个分支feature/demo,并切换到该分支。

    当功能完成:

    git flow feature finish demo

    它会有feature/demo分支合并到develop分支,然后切换回develop分支,并删除feature/demo分支。

    功能完成,要合并到主分支,这时可以执行

    git flow release start v0.7.0

    它会创建一个release/v0.7.0分支,并切换到该分支。

    然后在这里进行测试。如果测试没问题,则执行以下命令:

    git flow release finish v0.7.0

    它会将release/v0.7.0分支的内容合并到master分支和develop分支,并且打上tag v0.7.0,然后删除release/v0.7.0分支。
     

  • 相关阅读:
    Swift--多条件排序
    算法竞赛进阶指南 0x21 树与图的遍历
    数据库学习之视图和用户管理
    快速入门一篇搞定RocketMq-实现微服务实战落地
    ShardingSphere 云上实践:开箱即用的 ShardingSphere-Proxy 集群
    新消费时代,零售业的进与退?
    [AndroidStudio]_[初级]_[修改虚拟设备镜像文件的存放位置]
    力扣:141. 环形链表(Python3)
    基于ubuntu 20.04与cri-docker 搭建部署高可用k8s 1.25.3
    mysql-子查询
  • 原文地址:https://blog.csdn.net/apple_51426592/article/details/127856452