Git团队协作(.pdf)
Johannes Schindelin 序 ....................................................................................................................xi
Mark Atwood 序 ..................................................................................................................................xii
前言 ........................................................................................................................................................xiii
引言 .......................................................................................................................................................xvii
第一部分 制定工作流
第 1 章 团队作战 ................................................................................................................................2
1.1 团队成员 .....................................................................................................................................2
1.2 思维策略 .....................................................................................................................................4
1.3 团队会议 .....................................................................................................................................6
1.3.1 项目启动 ........................................................................................................................7
1.3.2 追踪进展 ........................................................................................................................7
1.3.3 培养同理心 ....................................................................................................................9
1.3.4 回顾 ................................................................................................................................9
1.4 Git 中的团队协作 .....................................................................................................................10
1.5 小结 ...........................................................................................................................................11
第 2 章 命令与控制 .........................................................................................................................12
2.1 项目治理 ...................................................................................................................................12
2.1.1 版权和贡献者协议 ......................................................................................................13
2.1.2 分发许可 ......................................................................................................................14
2.1.3 领导力模型 ..................................................................................................................15
2.1.4 行为守则 ......................................................................................................................15
vi | 目录
2.2 访问模型 ...................................................................................................................................16
2.2.1 适合分散贡献者仓库的模型 ......................................................................................18
2.2.2 适合并列贡献者仓库的模型 ......................................................................................20
2.2.3 共同维护的模型 ..........................................................................................................22
2.2.4 自定义访问模型 ..........................................................................................................24
2.3 小结 ...........................................................................................................................................25
第 3 章 分支策略 ..............................................................................................................................26
3.1 理解分支 ...................................................................................................................................26
3.2 挑选约定 ...................................................................................................................................27
3.3 几种约定 ...................................................................................................................................28
3.3.1 主线分支开发 ..............................................................................................................28
3.3.2 功能分支部署 ..............................................................................................................30
3.3.3 状态分支 ......................................................................................................................32
3.3.4 计划部署 ......................................................................................................................35
3.4 更新分支 ...................................................................................................................................40
3.5 小结 ...........................................................................................................................................43
第 4 章 工作流 ..................................................................................................................................45
4.1 初识工作流 ...............................................................................................................................45
4.1.1 记录工作过程 ..............................................................................................................46
4.1.2 记录编码的决定 ..........................................................................................................46
4.2 工单进展 ...................................................................................................................................47
4.3 基本工作流 ...............................................................................................................................49
4.3.1 使用同行评审的可信开发者 ......................................................................................50
4.3.2 需要质量保证团队的不可信开发者 ..........................................................................51
4.4 根据计划发布软件 ...................................................................................................................52
4.4.1 发布稳定版本 ..............................................................................................................52
4.4.2 正在进行的开发 ..........................................................................................................53
4.4.3 发布后的补丁 ..............................................................................................................53
4.5 非软件项目中的协作 ...............................................................................................................54
4.6 小结 ...........................................................................................................................................55
第二部分 在工作流中使用命令
第 5 章 单人团队 ..............................................................................................................................58
5.1 基于 issue 的版本控制 .............................................................................................................59
5.2 创建本地仓库 ...........................................................................................................................60
5.2.1 克隆已有的项目 ..........................................................................................................62
目录 | vii
5.2.2 将已有的项目迁移至 Git ............................................................................................63
5.2.3 初始化空项目 ..............................................................................................................65
5.2.4 查看历史记录 ..............................................................................................................65
5.3 使用分支工作 ...........................................................................................................................66
5.3.1 列出分支 ......................................................................................................................66
5.3.2 更新远程分支列表 ......................................................................................................67
5.3.3 使用不同的分支 ..........................................................................................................67
5.3.4 创建新的分支 ..............................................................................................................68
5.4 在仓库中添加更改 ...................................................................................................................70
5.4.1 在仓库中添加部分文件修改 ......................................................................................72
5.4.2 提交部分更改 ..............................................................................................................73
5.4.3 从暂存区移除文件 ......................................................................................................74
5.4.4 编写扩展提交消息 ......................................................................................................74
5.4.5 忽略文件 ......................................................................................................................75
5.5 使用标签 ...................................................................................................................................76
5.6 连接远程仓库 ...........................................................................................................................77
5.6.1 创建新的项目 ..............................................................................................................78
5.6.2 添加第二个远程连接 ..................................................................................................78
5.6.3 推送你的更改 ..............................................................................................................79
5.6.4 分支维护 ......................................................................................................................80
5.7 命令指南 ...................................................................................................................................81
5.8 小结 ...........................................................................................................................................82
第 6 章 回滚、还原、重置和变基 ...............................................................................................83
6.1 最佳实践 ...................................................................................................................................83
6.1.1 描述问题 ......................................................................................................................84
6.1.2 使用分支进行试验性的工作 ......................................................................................85
6.2 分步变基 ...................................................................................................................................88
6.2.1 开始变基 ......................................................................................................................88
6.2.2 文件删除造成的变基中冲突 ......................................................................................89
6.2.3 单个文件合并冲突造成的变基中冲突 ......................................................................92
6.3 定位丢失的工作概述 ...............................................................................................................94
6.4 还原文件 ...................................................................................................................................97
6.5 使用提交 ...................................................................................................................................98
6.5.1 修补提交 ......................................................................................................................99
6.5.2 使用 reset 合并提交 ...................................................................................................99
6.5.3 使用交互式变基修改提交 ........................................................................................101
6.5.4 撤销分支合并 ............................................................................................................106
6.6 撤销共享历史记录 .................................................................................................................108
6.6.1 还原之前的提交 ........................................................................................................108
viii | 目录
6.6.2 撤销共享分支的合并 ................................................................................................109
6.7 真正移除历史记录 .................................................................................................................114
6.8 命令指南 .................................................................................................................................115
6.9 小结 ........................................................................................................................................116
第 7 章 多人团队 ............................................................................................................................118
7.1 设置项目 .................................................................................................................................119
7.1.1 创建新项目 ................................................................................................................119
7.1.2 建立权限管理 ............................................................................................................120
7.1.3 上传项目仓库 ............................................................................................................121
7.1.4 在 README 中记录项目..........................................................................................123
7.2 设置开发者 .............................................................................................................................124
7.2.1 消费者 ........................................................................................................................124
7.2.2 贡献者 ........................................................................................................................126
7.2.3 维护者 ........................................................................................................................127
7.3 参与开发 .................................................................................................................................128
7.3.1 构建完美的提交 ........................................................................................................128
7.3.2 保持分支最新 ............................................................................................................131
7.3.3 评审工作 ....................................................................................................................133
7.3.4 合并完成的工作 ........................................................................................................135
7.3.5 解决合并和变基冲突 ................................................................................................136
7.3.6 发布工作 ....................................................................................................................137
7.4 样例工作流 .............................................................................................................................138
7.4.1 基于冲刺的工作流 ....................................................................................................138
7.4.2 没有同行评审的可信开发者 ....................................................................................141
7.4.3 需要独立质量保证的不可信开发者 ........................................................................142
7.5 小结 .........................................................................................................................................143
第 8 章 准备评审 ............................................................................................................................144
8.1 评审类型 .................................................................................................................................144
8.2 评审者类型 .............................................................................................................................145
8.3 用于代码评审的软件 .............................................................................................................146
8.4 评审 issue ................................................................................................................................146
8.5 应用提议更改 .........................................................................................................................147
8.5.1 共享仓库的设置 ........................................................................................................147
8.5.2 派生仓库的设置 ........................................................................................................148
8.5.3 签出提议分支 ............................................................................................................148
8.6 评审提议的更改 .....................................................................................................................149
8.7 准备你的反馈 .........................................................................................................................151
8.8 提交你的评估结果 .................................................................................................................151
目录 | ix
8.9 完成评审 .................................................................................................................................152
8.10 小结 .......................................................................................................................................153
第 9 章 寻找并修复 bug ...............................................................................................................154
9.1 使用 stash 进行紧急的 bug 修复 .........................................................................................155
9.2 比较历史记录的研究 .............................................................................................................157
9.3 使用 blame 调查文件历史版本 .............................................................................................159
9.4 使用 bisect 重演历史 ...........................................................................................................161
9.5 小结 .........................................................................................................................................163
第三部分 Git 托管平台
第 10 章 GitHub 上的开源项目 .................................................................................................166
10.1 开始使用 GitHub ..................................................................................................................167
10.1.1 创建账户 .................................................................................................................167
10.1.2 创建组织 .................................................................................................................169
10.1.3 个人仓库 .................................................................................................................170
10.2 使用 GitHub 上的公开仓库 .................................................................................................177
10.2.1 下载仓库快照 .........................................................................................................177
10.2.2 在本地工作 .............................................................................................................178
10.3 为项目做出贡献 ...................................................................................................................181
10.3.1 使用 issue 跟踪更改 ...............................................................................................181
10.3.2 派生项目 .................................................................................................................182
10.3.3 创建拉取请求 .........................................................................................................182
10.4 运营你自己的项目 ...............................................................................................................184
10.4.1 创建项目仓库 .........................................................................................................184
10.4.2 授权共同维护 .........................................................................................................185
10.4.3 评审并接受拉取请求 .............................................................................................186
10.4.4 发生合并冲突的拉取请求 .....................................................................................187
10.5 小结 .......................................................................................................................................188
第 11 章 Bitbucket 上的私有团队工作 ....................................................................................189
11.1 非公开项目的项目治理 .......................................................................................................189
11.2 开始使用 ...............................................................................................................................190
11.2.1 创建账户 .................................................................................................................190
11.2.2 在欢迎页面创建私有项目 .....................................................................................192
11.2.3 从信息中心创建私有项目 .....................................................................................193
11.2.4 设置你的新仓库 .....................................................................................................194
11.2.5 探索你的项目 .........................................................................................................196
x | 目录
11.2.6 编辑仓库中的文件 .................................................................................................197
11.3 项目设置 ...............................................................................................................................199
11.3.1 Wiki 页面中的项目文档 ........................................................................................200
11.3.2 使用 issue 跟踪你的更改 .......................................................................................202
11.4 访问控制 ...............................................................................................................................205
11.4.1 共享权限 .................................................................................................................207
11.4.2 每个开发者分别派生项目 .....................................................................................207
11.4.3 通过保护分支限制访问 .........................................................................................207
11.5 拉取请求 ...............................................................................................................................209
11.5.1 提交拉取请求 .........................................................................................................209
11.5.2 接受拉取请求 .........................................................................................................210
11.6 使用 Atlassian Connect 扩展 Bitbucket ...............................................................................210
11.7 小结 .......................................................................................................................................212
第 12 章 GitLab 上自行管理的协作 .........................................................................................213
12.1 入门 .......................................................................................................................................213
12.1.1 安装 GitLab .............................................................................................................213
12.1.2 设置管理账户 .........................................................................................................215
12.1.3 管理信息中心 .........................................................................................................216
12.2 项目 .......................................................................................................................................219
12.3 用户账户 ...............................................................................................................................221
12.3.1 创建用户账户 .........................................................................................................221
12.3.2 添加项目成员 .........................................................................................................223
12.4 群组 .......................................................................................................................................224
12.4.1 添加群组成员 .........................................................................................................225
12.4.2 将项目添加到群组 .................................................................................................227
12.5 访问控制 ...............................................................................................................................228
12.5.1 项目可见性 .............................................................................................................228
12.5.2 使用项目角色限制活动 .........................................................................................229
12.5.3 使用保护分支限制访问 .........................................................................................230
12.6 里程碑 ...................................................................................................................................231
12.7 小结 .......................................................................................................................................232
附录 A 奶油塔 .................................................................................................................................233
附录 B 安装最新版本的 Git ........................................................................................................235
附录 C 配置 Git ..............................................................................................................................240
附录 D SSH 密钥 ...........................................................................................................................245
关于作者 ..............................................................................................................................................248
关于封面 ..............................................................................................................................................248
**** Hidden Message *****
啥也不说了,感谢楼主分享哇! 额,看不懂在说神马~@_@ 啥也不说了,感谢楼主分享哇! 啥也不说了,感谢楼主分享哇! 正需要,支持楼主大人了! 啥也不说了,感谢楼主分享哇! 确实是难得好帖啊,顶先 啥也不说了,感谢楼主分享哇! 啥也不说了,感谢楼主分享哇!