Skip to content

Commit dfdb6bd

Browse files
committed
Add 02 github fundamentals
1 parent e6dbc24 commit dfdb6bd

File tree

4 files changed

+67
-4
lines changed

4 files changed

+67
-4
lines changed

chapters/01-introduction.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#介绍
22

3-
##什么是Github
3+
###什么是Github
44

55
Wiki百科上是这么说的
66

@@ -26,7 +26,7 @@ Wiki百科上是这么说的
2626
等等。看上去像是大餐,但是你还需要了解点什么?
2727

2828

29-
##版本管理与软件部署
29+
###版本管理与软件部署
3030

3131
jQuery[^jQuery]在发布版本``2.1.3``,一共有152个commit。我们可以看到如下的提交信息:
3232

@@ -38,7 +38,7 @@ jQuery[^jQuery]在发布版本``2.1.3``,一共有152个commit。我们可以
3838
- ...
3939

4040

41-
##Github与Git
41+
###Github与Git
4242

4343
> Git是一个分布式的版本控制系统,最初由Linus Torvalds编写,用作Linux内核代码的管理。在推出后,Git在其它项目中也取得了很大成功,尤其是在Ruby社区中。目前,包括Rubinius、Merb和Bitcoin在内的很多知名项目都使用了Git。Git同样可以被诸如Capistrano和Vlad the Deployer这样的部署工具所使用。
4444

chapters/02-github-fundamentals.md

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,64 @@
1-
#基本概念
1+
#基本知识
2+
3+
##Git
4+
5+
6+
从一般开发者的角度来看,git有以下功能:
7+
8+
1. 从服务器上克隆数据库(包括代码和版本信息)到单机上。
9+
2. 在自己的机器上创建分支,修改代码。
10+
3. 在单机上自己创建的分支上提交代码。
11+
4. 在单机上合并分支。
12+
5. 新建一个分支,把服务器上最新版的代码fetch下来,然后跟自己的主分支合并。
13+
6. 生成补丁(patch),把补丁发送给主开发者。
14+
7. 看主开发者的反馈,如果主开发者发现两个一般开发者之间有冲突(他们之间可以合作解决的冲突),就会要求他们先解决冲突,然后再由其中一个人提交。如果主开发者可以自己解决,或者没有冲突,就通过。
15+
8. 一般开发者之间解决冲突的方法,开发者之间可以使用pull 命令解决冲突,解决完冲突之后再向主开发者提交补丁。
16+
17+
从主开发者的角度(假设主开发者不用开发代码)看,git有以下功能:
18+
19+
1. 查看邮件或者通过其它方式查看一般开发者的提交状态。
20+
2. 打上补丁,解决冲突(可以自己解决,也可以要求开发者之间解决以后再重新提交,如果是开源项目,还要决定哪些补丁有用,哪些不用)。
21+
3. 向公共服务器提交结果,然后通知所有开发人员。
22+
23+
###Git初入
24+
25+
如果是第一次使用Git,你需要设置署名和邮箱:
26+
27+
$ git config --global user.name "用户名"
28+
$ git config --global user.email "电子邮箱"
29+
30+
将代码仓库clone到本地,其实就是将代码复制到你的机器里,并交由Git来管理:
31+
32+
$ git clone git@github.com:someone/symfony-docs-chs.git
33+
34+
你可以修改复制到本地的代码了(symfony-docs-chs项目里都是rst格式的文档)。当你觉得完成了一定的工作量,想做个阶段性的提交:
35+
36+
向这个本地的代码仓库添加当前目录的所有改动:
37+
38+
$ git add .
39+
40+
或者只是添加某个文件:
41+
42+
##Github
43+
44+
![Github Roam](../img/github-roam-create.jpg)
45+
46+
![Github Roam](../img/project-init.jpg)
47+
48+
多种方式
49+
50+
> …or create a new repository on the command line
51+
52+
echo "# github-roam" >> README.md
53+
git init
54+
git add README.md
55+
git commit -m "first commit"
56+
git remote add origin git@github.com:phodal/github-roam.git
57+
git push -u origin master
58+
59+
> …or push an existing repository from the command line
60+
61+
git remote add origin git@github.com:phodal/github-roam.git
62+
git push -u origin master
63+
64+

img/github-roam-create.jpg

59.4 KB
Loading

img/project-init.jpg

127 KB
Loading

0 commit comments

Comments
 (0)