Skip to content

Instantly share code, notes, and snippets.

@onlytiancai
Created October 16, 2012 05:53
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save onlytiancai/3897417 to your computer and use it in GitHub Desktop.
Save onlytiancai/3897417 to your computer and use it in GitHub Desktop.
git分支使用规范

分支管理

最少有三个长期分支

  • master: 用于生产环境部署
  • testing: 用于测试环境测试
  • dev: 用于日常开发

有一些临时分支

  • feature-xxx: 用于增加一个新功能
  • hotfix-xxx: 用于修复一个紧急bug

常见任务

增加一个新功能

(dev)$: git checkout -b feature-xxx            # 从dev建立特性分支
(feature-xxx)$: blabla                         # 开发
(feature-xxx)$: git add xxx
(feature-xxx)$: git commit -m 'commit comment'
(dev)$: git merge feature-xxx --no-ff          # 把特性分支合并到dev

修复一个紧急bug

(master)$: git checkout -b hotfix-xxx         # 从master建立hotfix分支
(hotfix-xxx)$: blabla                         # 开发
(hotfix-xxx)$: git add xxx
(hotfix-xxx)$: git commit -m 'commit comment'
(master)$: git merge hotfix-xxx --no-ff       # 把hotfix分支合并到master,并上线到生产环境
(dev)$: git merge hotfix-xxx --no-ff          # 把hotfix分支合并到dev,同步代码

测试环境测试代码

(testing)$: git merge dev --no-ff             # 把dev分支合并到testing,然后在测试环境拉取并测试,配置管理人员操作

生产环境大版本上线

(master)$: git merge testing --no-ff          # 把testing测试好的代码合并到master,运维人员操作
(master)$: git tag -a v0.1 -m '部署包版本名'  #给大版本命名,打Tag
@jiangxin
Copy link

Git文档里介绍的Git工作流就很好,使用下面命令即可调出:

$ git help workflows

其中 master 分支 和 maint 分支合并时用到的 git merge --ff-only 参数非常有意义。
可以避免在 maint 分支的 hotfix 未合并到主线。

你在文档里频繁使用的参数 --no-ff ,其用处主要是让 git log --first-parents 更清晰一些,
还没有其他作用么?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment