dyok 发表于 2018-1-15 15:23:59

Git branch (分支学习)

  master分支是整个项目的主分支。
  所有其他分支都直接或间接源自master。master分支是可直接用于产品发布的代码。
  develop分支反映最新的开发进程。
  develop中的代码总是可以完整build的。当develop中的代码进入稳定状态(修复了绝大多数bug)准备release时,所有develop中的更改将通过release branch最终merge到master。
  除master和develop以外的分支都是临时分支。当这些临时分支完成其使命,就可以删除它们。我们先看feather分支。
  feather分支用于某个新feather的开发,源自develop,并最终merge到develop。
  feather分支最终的结局要么合并到develop branch,要么被抛弃。feather分支用如下命令创建:
  # git checkout –b my feather develop
  完成后将这个feather合并到develop:
  # git checkout develop
  # git merge --no-ff myfeather
  # git branch –d myfeather
  # git push origin develop
  合并时--no-ff选项避免fast forward。使用该选项和不使用该选项得到的分支路线图分别如下:
http://note.youdao.com/yws/res/230/2E5EF08F801541348B705EC08EC77CFE​
  release分支用于准备新版本的发布。源自develop,merge到develop和master。
  release分支仅修复小的bug,完成准备版本号,build date等工作。而develop分支可以同时开始新feather的开发。该分支上修复的bug需要merge到develop,并在该分支完成时merge到master。此时需要给master打上tag,标记这个新的release。
  Hotfix分支用于紧急bug修复,源自master,merge到develop和master。
  对于已发布的产品,可能有意外的紧急bug需要修复。hotfix branch可以避免修复bug的工作影响develop branch。
  创建hotfix branch:
  # git checkout -b hotfix-x.y master
  完成hotfix branch:
  # git checkout master
  # git merge --no-ff hotfix-x.y
  # git tag –a x.y.z
  # git checkout develop
  # git merge --no-ff hotfix-x.y
  # git branch –d hotfix-x.y
  这里有个例外就是,如果hotfix发生时有正在进行的release branch,那么将hotfix merge到release,而release最终会merge到develop和master。
页: [1]
查看完整版本: Git branch (分支学习)