Github Flow 文档

文档地址


前言

GitHub Flow is a lightweight, branch-based workflow that supports teams and projects where deployments are made regularly. This guide explains how and why GitHub Flow works.

GitHub Flow 是一个基于分支的轻量级工作流。它适用于团队开发与定期需要发布的项目。这个文档解释了如何使用与为何使用github flow。

1.Create a branch 创建分支

Create a branch.png

When you're working on a project, you're going to have a bunch of different features or ideas in progress at any given time – some of which are ready to go, and others which are not. Branching exists to help you manage this workflow.
When you create a branch in your project, you're creating an environment where you can try out new ideas. Changes you make on a branch don't affect the master branch, so you're free to experiment and commit changes, safe in the knowledge that your branch won't be merged until it's ready to be reviewed by someone you're collaborating with.
开发项目的时候,你可能需要创建分支去支持一些新特性,实现一些新想法。但是有些分支是可以发布部署的,有些则没有准备好。branch就是为了解决这个问题存在的。在项目里创建了一个新的分支,意味着你可以在新分支里面尝试新的想法。
分支的任何改动,不会影响master主分支。所以你可以尽情的改动,尝试并且comm你的改动。但是如果你想merge分支,你得确认你的代码可以被合作者们review.
ProTip
Branching is a core concept in Git, and the entire GitHub flow is based upon it. There's only one rule: anything in the master branch is always deployable.
branch-分支是git中的核心概念。整个Github flow 都基于branch。而且准则只有一个:任何主分支的内容都是可部署的。
Because of this, it's extremely important that your new branch is created off of master when working on a feature or a fix. Your branch name should be descriptive (e.g., refactor-authentication, user-content-cache-key, make-retina-avatars), so that others can see what is being worked on.
也正是因为如此,在主分支以外创建新分支去处理问题与实现新需求是及其重要的。分支命名记得需要规范易懂,这样便于合作开发。

2.Add commits 创建分支

Add commits.png

Once your branch has been created, it's time to start making changes. Whenever you add, edit, or delete a file, you're making a commit, and adding them to your branch. This process of adding commits keeps track of your progress as you work on a feature branch.
Commits also create a transparent history of your work that others can follow to understand what you've done and why. Each commit has an associated commit message, which is a description explaining why a particular change was made. Furthermore, each commit is considered a separate unit of change. This lets you roll back changes if a bug is found, or if you decide to head in a different direction.
创建了new branch,你就可以在该分支进行内容的改动。添加删除改动文件,意味着你也要提交改动并且改动需要被添加到branch中。
提交都是有完整详细的记录,任何资源的修改都有。它的意义在于告诉别人你做了什么操作,以及为什么。
每个commit对有对应的详细说明。说明需要解释你做了什么改动,为什么改动。而且,每个commit都可以被视为change的一个小组成单元。这有助于你回溯来改BUG。
ProTip
Commit messages are important, especially since Git tracks your changes and then displays them as commits once they're pushed to the server. By writing clear commit messages, you can make it easier for other people to follow along and provide feedback.
commit的说明非常重要,因为代码连同改动和说明都被推送到服务器(一旦被推到server,git追踪的改动会被显示为commits)。书写清晰易懂的说明有助于他人理解你的改动。

3.Open a Pull Request

Open a Pull Request.png

Pull Requests initiate discussion about your commits. Because they're tightly integrated with the underlying Git repository, anyone can see exactly what changes would be merged if they accept your request.
You can open a Pull Request at any point during the development process: when you have little or no code but want to share some screenshots or general ideas, when you're stuck and need help or advice, or when you're ready for someone to review your work. By using GitHub's @mention system in your Pull Request message, you can ask for feedback from specific people or teams, whether they're down the hall or ten time zones away.
Pull requests 等于创建了一个会话,专门讨论你的commits。因为他们和基础git仓库是紧密集成的,所以任何人都可以了解到他们在合并代码之后会有哪些改动。
你可以在任何时候开启pull request:截屏,新想法,需要帮助都可以。(所以pull request本质上就是一种机制,让当前的开发者告诉其余成员,一个功能已经完成。维护者合并之后关闭这个PR。)
ProTip
Pull Requests are useful for contributing to open source projects and for managing changes to shared repositories. If you're using a Fork & Pull Model, Pull Requests provide a way to notify project maintainers about the changes you'd like them to consider. If you're using a Shared Repository Model, Pull Requests help start code review and conversation about proposed changes before they're merged into the master branch.
Pull Requests在向开源项目贡献代码,管理共享项目的改动的时候都很管用。Pull Requests提供了一个机制帮助开发者们在合并代码到master分支之前充分讨论和code review。

4.Discuss and review your code

Discuss and review your code.png

Once a Pull Request has been opened, the person or team reviewing your changes may have questions or comments. Perhaps the coding style doesn't match project guidelines, the change is missing unit tests, or maybe everything looks great and props are in order. Pull Requests are designed to encourage and capture this type of conversation.
You can also continue to push to your branch in light of discussion and feedback about your commits. If someone comments that you forgot to do something or if there is a bug in the code, you can fix it in your branch and push up the change. GitHub will show your new commits and any additional feedback you may receive in the unified Pull Request view.
Pull Request 开启之后,review你代码和改动的人会对相关内容有疑问,例如代码风格不符合标准,缺少单元测试。Pull Request 设计的初衷就是鼓励这种类型的讨论。
Pull Request发起之后你仍然可以继续提交改动到branch。Github会显示你最新的commits。
ProTip
Pull Request comments are written in Markdown, so you can embed images and emoji, use pre-formatted text blocks, and other lightweight formatting.
Pull Request使用的是markdown,所以你可以放emoji和images等等等等。

5.Deploy


图像.png

With GitHub, you can deploy from a branch for final testing in production before merging to master.
Once your pull request has been reviewed and the branch passes your tests, you can deploy your changes to verify them in production. If your branch causes issues, you can roll it back by deploying the existing master into production.
在github上你可以在branch合并到master分支上之前,进行测试等配置。一切都OK了,就可以进行部署了。发生任何问题你都可以回滚。

6.Merge

merge.png

Now that your changes have been verified in production, it is time to merge your code into the master branch.
Once merged, Pull Requests preserve a record of the historical changes to your code. Because they're searchable, they let anyone go back in time to understand why and how a decision was made.
现在所有的改动都已经被验证过,可以把代码合并到主分支。一旦合并, Pull Requests会保存你更改的历史记录。因为他们是可查询的。这样对任何人来说,记录都是可回溯的。
ProTip
By incorporating certain keywords into the text of your Pull Request, you can associate issues with code. When your Pull Request is merged, the related issues are also closed. For example, entering the phrase Closes #32 would close issue number 32 in the repository. For more information, check out our help article.
通过把特定关键词合并到你的Pull Request,你可以将code和issue关联。当你的Pull Request被合并之后,相关的issues会被closed。

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 206,839评论 6 482
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 88,543评论 2 382
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 153,116评论 0 344
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 55,371评论 1 279
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 64,384评论 5 374
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 49,111评论 1 285
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,416评论 3 400
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,053评论 0 259
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 43,558评论 1 300
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,007评论 2 325
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,117评论 1 334
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,756评论 4 324
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,324评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,315评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,539评论 1 262
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,578评论 2 355
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,877评论 2 345

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,294评论 0 10
  • Lesson 3: Using GitHub to Collaborate 3.1 Creating a GitH...
    赤乐君阅读 6,038评论 3 11
  • 前言:这个是官方教程,看完觉得写的挺浅显易懂的,于是翻译一下给需要的人,本人才疏学浅,有翻译的不到位的地方欢迎指正...
    道阻且长_行则将至阅读 1,501评论 0 9
  • “等待最后一眼,最后一遍,最后一天,最后一点,滴滴答答,消失的时间,最后这场爱情,难逃浩劫......” ...
    来听香阅读 444评论 0 1
  • 姓名:张昱宁 公司:上海缘缀包装材料有限公司 六项精进313期学员 【日精进打卡第227天】 【知~学习】 《六项...
    听风煮酒阅读 175评论 0 0