reference : http://fle.github.io/an-efficient-git-workflow-for-midlong-term-projects.html

Our full-web  project has been going on for nearly two years and is running in production for over 18 months. I think it's my first project without any headache about our codebase and VCS management. So, I'll present our GIT workflow which has proven to be very effective for now.

Context

  • Several developers
  • Several staging/pre-production servers, several (non-synchronous) production servers
  • Monthly releases (more or less) with delivery on staging, then on production servers
  • On servers, basecode is directly pulled from the GIT repository with fabric

Rules

To handle this, we have set some simple rules:

  1. One (and only one) maintainer, who manage GIT repository and releases
  2. Never commit directly on master
  3. Never rebase master on any branch
  4. Do not get out of planned workflow

Workflow

Master branch

Our branch master is the common trunk and simply contains all the codebase of the next release. Since we don't work directly on it, it evolves mainly with merges.

Development branches

When a developer starts a new feature or a bugfix, he creates a new branch from master HEAD

$ (master) git checkout -b featureA
$ (featureA) git commit -a -m "featureA part 1"
$ (featureA) git commit -a -m "featureA part 2"

He follows branch master evolution and regularly ensures his code still works, by rebasing his branch featureA on branch master.

$ (featureA) git rebase master

When his developments are done (commits fa1 / fa2 in schema below), he does a last rebase. Thanks to this:

  • he ensures that the maintainer will be able to merge easily (maintainer should not need to read code deeply and search why there are conflicts)
  • if tests pass on development branch after rebase, they should pass on master after merge, so we ensure that branch ``master`` is always working well

Possibly, it will be the good time to clean the development branch to let it neat just when it is finished.

The maintainer can now merge this branch in master peacefully, without big conflict troubles. As the maintainer, I like to use no-ff option to force a merge commit, so history can stay really readable (we easily see where the branch has started and where it has been merged).

$ (master) git merge --no-ff featureA

Now that the branch has been merged, the developer should remove his development branch.

$ (master) git branch -d featureA
$ (master) git push origin :featureA

Stable branches

When we prepare a release, we update CHANGELOG (with our workflow, a git log --oneline should be quite clear to do that) and tag the branch master (optional), then we start a stable branch.

$ (master) git tag 1.0
$ (master) git checkout -b stable1.0
$ (stable1.0) git push origin stable1.0

This branch is deployed on different servers.

While development goes on, we possibly have to do some hotfixes (for example: commit hf1 in schema below), that must be sent in production quickly. These hotfixes are done directly on concerned stable branch.

Regularly, the maintainer merges stable branch in master to bring back these commits. This action is particularly important before the next release.

 
$ (master) git merge --no-ff stable1.0

We found this method really useful because:

  • each stable branch has its own life and doesn't take care of branch master evolution, so we can hotfix stable branche freely and without stress
  • we ensure that no hotfix commit has been lost before next release (avoid regressions)

A complete history example

Conclusion

Of course, there are several GIT workflows which can be very efficient, but we found many advantages in working with this method, and no real issue:

  • Branch master is always clean and working well
  • Developers don't care about GIT whole workflow
  • We can fix stable branch without asking ourselves what happened on master since last release
  • We ensure that each stable release contains new features and possible fixes
  • Always working with branches and using``-no-ff``option make history really clear !
  • This workflow is scalable (number of developers or branches doesn't really matter)

[Git] An efficient GIT workflow for mid/long term projects的更多相关文章

  1. git项目实战常用workflow和命令

    一个从无到有的项目大体经历-创建项目目录,创建repo,配置过滤集,配置git user,导入已有基础代码入库,将库放到central去,建立分支,修改代码,checkin代码,分支上 测试验证代码, ...

  2. Git基本命令 -- 创建Git项目

    在这里下载git:https://git-scm.com/ 安装的时候, 如果是windows系统的话, 可以勾选unix的命令行工具, 这样在windows命令行下会多出很多命令, 例如ls. Gi ...

  3. git push and git pull

    原文链接 git push 通常对于一个本地的新建分支,例如git checkout -b develop, 在develop分支commit了代码之后,如果直接执行git push命令,develo ...

  4. git init和git init -bare区别

    1 Git init  和 git init –bare 的区别 用"git init"初始化的版本库用户也可以在该目录下执行所有git方面的操作.但别的用户在将更新push上来的 ...

  5. 小丁带你走进git世界一-git简单配置

    小丁带你走进git世界一-git简单配置 1.github的简单配置 配置提交代码的信息,例如是谁提交的代码之类的. git config  –global user.name BattleHeaer ...

  6. Git(远程仓库:git@oschina)-V2.0

    1.注册git@osc(也就是“码云”) 这里会提示注册密码==push密码,反正一定要记住的东西.   2.安装git 这里要设置个人信息 git config --list //查看git信息 g ...

  7. git pull和git fetch的区别

    Git中从远程的分支获取最新的版本到本地有这样2个命令:1. git fetch:相当于是从远程获取最新版本到本地,不会自动merge Git fetch origin master git log ...

  8. [.net 面向对象程序设计进阶] (26) 团队开发利器(五)分布式版本控制系统Git——图形化Git客户端工具TortoiseGit

    [.net 面向对象程序设计进阶] (26) 团队开发利器(五)分布式版本控制系统Git——图形化Git客户端工具TortoiseGit 读前必备: 接上篇: 分布式版本控制系统Git——使用GitS ...

  9. Git:Git初体验——Git安装配置

    作为即将成为一个程序员的男人,一直在听别人说Git多好多好,之前也随便了解了一些,但是始终没有决心去学会.现在大四了,只有毕设和一门开学六七周只去过一次课的全员必修课外,也没有什么事情做,何不去做这些 ...

随机推荐

  1. java内存溢出分析工具

    http://www.cnblogs.com/preftest/archive/2011/12/08/2281322.html java内存溢出分析工具:jmap使用实战 在一次解决系统tomcat老 ...

  2. JavaScript中正则的使用(1)

    通过例子学习正则中的常见语法(1) $num javascript var a = 'javascript'; var b = a.replace(/(java)(script)/gi, '$2-$1 ...

  3. 【Java】 参数的传递:值传递与引用传递讨论

    内容稍多,可直接看第4点的讨论结果 前言 在涉及到传递参数给方法时,容易出现一些参数传递错误的问题,这就涉及到了参数的传递问题,必须搞清楚:参数是如何传递到方法中的?一般来说,参数的传递可以分为两种: ...

  4. pandas实战——对星巴克数据的分析

    一.实验对象 实验对象为星巴克在全球的门店数据,我们可以使用pandas对其进行简单的分析,如分析每个国家星巴克的数量,根据门店数量对国家进行排序等. 二.数据分析 1.读取数据并获取数据行列数 首先 ...

  5. python3下django连接mysql数据库

    1.安装pymysql pip install pymysql 有一点需要注意,有的系统(比如ubuntu16.04)同时安装了python2和python3,而比较新的django需要在python ...

  6. webview内部跳转判断

    重写webview内的方法 webView.setWebViewClient(new WebViewClient() { @Override // 在点击请求的是链接是才会调用,重写此方法返回true ...

  7. React Native踩坑之FlatList组件中的onEndReached

    最近在做一个RN项目,有使用到FlatList这样一个RN封装的组件去做上拉加载更多功能,在iOS和Android平台上,总结了以下几个遇到的问题及解决方案 1. 进入页面onReached开始就被触 ...

  8. 【原创】MHA二次检测功能测试

    MHA提供了很多扩展的功能,其中有一个参数是secondary_check_script,这个参数可以使我们自定义扩展多路由,多链路的二次检测功能.减少网络故障切换,降低脑裂的发生. 在虚拟机上做了如 ...

  9. OpenVAS漏洞扫描基础教程之创建用户

    OpenVAS漏洞扫描基础教程之创建用户 OpenVAS管理服务 默认情况下,OpenVAS服务仅创建了一个名为admin的用户,而且是管理员用户(拥有最高的权限).如果想要其它客户端登陆的话,不可能 ...

  10. es6新增功能

    声明命令 1. let命令 ES6新增了let命令,用来声明变量.它的用法类似于var,但是所声明的变量,只在let命令所在的代码块内有效.下面代码在代码块之中,分别用let和var声明了两个变量.然 ...