`
wbj0110
  • 浏览: 1611145 次
  • 性别: Icon_minigender_1
  • 来自: 上海
文章分类
社区版块
存档分类
最新评论

基于Github参与eoe的开源项目指南

阅读更多

Github是一个非常棒的项目托管网站,基于Git的原理,让我们可以非常方便的多人协作参与到开源项目里来,前几日eoe把android客户 端开源了,看到不少同学非常积极的参与进来或者想参与进来,但是不是很熟悉Git或Github,有不少困惑和疑问,我这里写一篇如何基于Github参 与eoe开源项目的指南。

 

注:
Git的理念和基本操作和推荐的使用方式我就不详细说了,大家可以参考诸如git-flow这样的规范或其他文章,我们这次只讲如何基于Github多人协助。

 

协助约定

 

  • 1.每个人都可以fork一份自己的repo,所有的修改都在自己私有的repo上进行;
  • 2.修改完成,测试通过后通过给主repo发pull request请求合并;
  • 3. 主repo(eoecn/android-app)的管理团队收到pull request请求后,review代码,合并进来;
  • 4.个人的repo需及时和主repo保持同步;

接下来,我们详细说明每个步骤是如何操作的。

 

第1步:fork一份自己的repo
打开eoecn/android-app在Github上的主页(https://github.com/eoecn/android-app/) ,如下
Screen Shot 2013-04-29 at 8.30.29 AM.png

 

在右上角点击“fork”就可以fork一份自己的repo,其url类似于https://github.com/IceskYsl/android-app ,现在我们就有了一份自己的repo,接下里我们的操作都是基于自己的repo(我这里就是 iceskysl/android-app) 。

 

第2步:clone自己的repo
上面我们fork了自己的repo,接着就可以clone下来了,先到自己的repo主页(https://github.com/IceskYsl/android-app ),找到repo的git地址,诸如这样 git@github.com:IceskYsl/android-app.git,然后clone到本地

 

1
2
3
4
5
6
7
ice@mac:/source/labs/git > git clone git@github.com:IceskYsl/android-app.git
Cloning into 'android-app'...
remote: Counting objects: 490, done.
remote: Compressing objects: 100% (296/296), done.
remote: Total 490 (delta 162), reused 490 (delta 162)
Receiving objects: 100% (490/490), 2.22 MiB | 231 KiB/s, done.
Resolving deltas: 100% (162/162), done.

第3步:查看和添加远程分支
我们接着cd到项目里,看下当前的git远程仓库,如下

 

1
2
3
4
ice@mac:/source/labs/git > cd android-app/
ice@mac:/source/labs/git/android-app > git remote -v
origin     git@github.com:IceskYsl/android-app.git (fetch)
origin     git@github.com:IceskYsl/android-app.git (push)

可以看到当前的项目里有一个叫'origin'的远程仓库(就是我们刚刚clone的时候加入的),为了能很好的和主仓库(eoecn/android-app)保持代码同步,我们需要添加一个主仓库的远程仓库,命令如下

 

1
2
3
4
5
6
ice@mac:/source/labs/git/android-app > git remote add eoecn git@github.com:eoecn/android-app.git
ice@mac:/source/labs/git/android-app > git remote  -v
eoecn     git@github.com:eoecn/android-app.git (fetch)
eoecn     git@github.com:eoecn/android-app.git (push)
origin     git@github.com:IceskYsl/android-app.git (fetch)
origin     git@github.com:IceskYsl/android-app.git (push)

好了,到这里仓库就添加完成了,为了保持和主仓库的代码一致,我们接着需要获取下主仓库的最新代码。

 

第4步:获取主仓库最新代码

 

1
2
3
4
5
6
7
8
9
ice@mac:/source/labs/git/android-app > git fetch eoecn
remote: Counting objects: 279, done.
remote: Compressing objects: 100% (94/94), done.
remote: Total 222 (delta 128), reused 181 (delta 89)
Receiving objects: 100% (222/222), 261.66 KiB | 98 KiB/s, done.
Resolving deltas: 100% (128/128), completed with 50 local objects.
From github.com:eoecn/android-app
   bd0f14b..6b9533d  master     -> eoecn/master
ice@mac:/source/labs/git/android-app > 

第5步:合并到自己的分支里

 

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
ice@mac:/source/labs/git/android-app > git merge eoecn/master
Updating c7b152c..6b9533d
Fast-forward
 README.md                                          |    1 +
 source/.classpath                                  |    4 +-
 source/AndroidManifest.xml                         |   17 +-
 source/libs/zxing-1.6.jar                          |  Bin 0 -> 245201 bytes
 source/project.properties                          |    2 +-
 source/res/layout/qr_code_scan.xml                 |   33 ++
 source/res/layout/umeng_fb_send_feedback.xml       |    6 +-
 source/res/layout/user_login_activity.xml          |   13 +-
 source/res/raw/beep.ogg                            |  Bin 0 -> 6401 bytes
 source/res/values-zh/strings.xml                   |  176 ++++++-----
 source/res/values/colors.xml                       |    7 +
 source/res/values/dimens.xml                       |  113 +++----
 source/res/values/ids.xml                          |   18 +-
 source/res/values/strings.xml                      |  176 ++++++-----
 source/res/values/styles.xml                       |    7 +-
 source/src/cn/eoe/app/biz/BlogsDao.java            |    3 -
 source/src/cn/eoe/app/biz/DetailDao.java           |    1 -
 source/src/cn/eoe/app/biz/NewsDao.java             |    4 -
 source/src/cn/eoe/app/biz/SearchDao.java           |    4 +-
 source/src/cn/eoe/app/biz/WikiDao.java             |    1 -
 source/src/cn/eoe/app/entity/BlogContentItem.java  |    2 +-
 source/src/cn/eoe/app/entity/NewsContentItem.java  |    2 +-
 .../cn/eoe/app/entity/base/BaseResponseData.java   |    2 +-
 .../cn/eoe/app/indicator/TitlePageIndicator.java   |    5 +-
 .../eoe/app/slidingmenu/SlidingActivityHelper.java |    2 +-
 source/src/cn/eoe/app/ui/DetailsActivity.java      |    3 -
 source/src/cn/eoe/app/ui/MainActivity.java         |   36 +--
 source/src/cn/eoe/app/ui/SplashActivity.java       |   17 +-
 source/src/cn/eoe/app/ui/UserCenterActivity.java   |    8 +-
 source/src/cn/eoe/app/ui/UserLoginActivity.java    |  249 ++++++++-------
 source/src/cn/eoe/app/ui/UserLoginUidActivity.java |    2 +
 source/src/cn/eoe/app/ui/base/BaseActivity.java    |    4 +-
 .../cn/eoe/app/ui/base/BaseFragmentActivity.java   |    1 -
 .../app/ui/base/BaseSlidingFragmentActivity.java   |    6 +-
 source/src/cn/eoe/app/utils/MD5.java               |    7 +-
 source/src/cn/eoe/app/utils/PopupWindowUtil.java   |    1 -
 source/src/cn/eoe/app/utils/Utility.java           |    1 -
 source/src/cn/eoe/app/view/BlogFragment.java       |    6 -
 source/src/cn/eoe/app/view/NewsFragment.java       |    6 -
 source/src/cn/eoe/app/view/UserIntroFragment.java  |    4 +-
 source/src/cn/eoe/app/view/WikiFragment.java       |    6 -
 source/src/cn/eoe/app/widget/XListView.java        |    2 +-
 source/src/cn/eoe/app/widget/XListViewFooter.java  |    2 +-
 source/src/cn/eoe/app/widget/XListViewHeader.java  |    2 +-
 source/src/com/google/zxing/CaptureActivity.java   |  216 +++++++++++++
 .../com/google/zxing/camera/AutoFocusCallback.java |   48 +++
 .../zxing/camera/CameraConfigurationManager.java   |  288 +++++++++++++++++
 .../src/com/google/zxing/camera/CameraManager.java |  326 ++++++++++++++++++++
 .../com/google/zxing/camera/FlashlightManager.java |  150 +++++++++
 .../zxing/camera/PlanarYUVLuminanceSource.java     |  133 ++++++++
 .../com/google/zxing/camera/PreviewCallback.java   |   59 ++++
 .../zxing/decoding/CaptureActivityHandler.java     |  143 +++++++++
 .../google/zxing/decoding/DecodeFormatManager.java |  104 +++++++
 .../com/google/zxing/decoding/DecodeHandler.java   |  115 +++++++
 .../com/google/zxing/decoding/DecodeThread.java    |   85 +++++
 .../com/google/zxing/decoding/FinishListener.java  |   47 +++
 .../com/google/zxing/decoding/InactivityTimer.java |   71 +++++
 source/src/com/google/zxing/decoding/Intents.java  |  190 ++++++++++++
 .../zxing/view/ViewfinderResultPointCallback.java  |   34 ++
 .../src/com/google/zxing/view/ViewfinderView.java  |  183 +++++++++++
 60 files changed, 2738 insertions(+), 416 deletions(-)
 create mode 100644 source/libs/zxing-1.6.jar
 create mode 100644 source/res/layout/qr_code_scan.xml
 create mode 100644 source/res/raw/beep.ogg
 create mode 100644 source/src/com/google/zxing/CaptureActivity.java
 create mode 100644 source/src/com/google/zxing/camera/AutoFocusCallback.java
 create mode 100644 source/src/com/google/zxing/camera/CameraConfigurationManager.java
 create mode 100644 source/src/com/google/zxing/camera/CameraManager.java
 create mode 100644 source/src/com/google/zxing/camera/FlashlightManager.java
 create mode 100644 source/src/com/google/zxing/camera/PlanarYUVLuminanceSource.java
 create mode 100644 source/src/com/google/zxing/camera/PreviewCallback.java
 create mode 100644 source/src/com/google/zxing/decoding/CaptureActivityHandler.java
 create mode 100644 source/src/com/google/zxing/decoding/DecodeFormatManager.java
 create mode 100644 source/src/com/google/zxing/decoding/DecodeHandler.java
 create mode 100644 source/src/com/google/zxing/decoding/DecodeThread.java
 create mode 100644 source/src/com/google/zxing/decoding/FinishListener.java
 create mode 100644 source/src/com/google/zxing/decoding/InactivityTimer.java
 create mode 100644 source/src/com/google/zxing/decoding/Intents.java
 create mode 100644 source/src/com/google/zxing/view/ViewfinderResultPointCallback.java
 create mode 100644 source/src/com/google/zxing/view/ViewfinderView.java

哎哟,正好获取到主分支合并了添加二维码扫描的代码。

 

第6步:本地修改代码,提交到自己的repo
本地代码保持最新后,就可以修改或者添加代码了,比如你添加新的功能获取修复其他的bug,这里我示范着在README.md里添加一个指向本文链接的信息,操作步骤如下:
ice@mac:/source/labs/git/android-app > mate .
打开README.md文件,添加如下信息
Screen Shot 2013-04-29 at 9.21.26 AM.png

 

接着,我把本次修改添加到本地的仓库里,步骤如下

 

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
ice@mac:/source/labs/git/android-app > git st
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#     modified:   README.md
#
no changes added to commit (use "git add" and/or "git commit -a")
ice@mac:/source/labs/git/android-app > git add .
ice@mac:/source/labs/git/android-app > git commit -m "添加链接到'基于Github参与eoe的开源项目指南'的链接"
[master 39087c4] 添加链接到'基于Github参与eoe的开源项目指南'的链接
 1 file changed, 3 insertions(+)

最后我把本次修改提交到我自己的远程仓库(IceskYsl/android-app)中,操作如下

 

1
2
3
4
5
6
7
8
ice@mac:/source/labs/git/android-app > git push  origin master
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 522 bytes, done.
Total 3 (delta 1), reused 0 (delta 0)
To git@github.com:IceskYsl/android-app.git
   1c960df..39087c4  master -> master

第7步:给主repo发pull request
提交到自己repo后,就可以给主repo发一个请求合并的pull request,操作步骤是这样的
打开https://github.com/IceskYsl/android-appPull,点击右上角的“ request”,会打开创建pull request的界面,如下
Screen Shot 2013-04-29 at 9.35.50 AM.png

 

第8步:主repo收到pull request后,可以merge进来

 

这个可以review修改,如果没问题就可以直接“Merge pull requst”
Screen Shot 2013-04-29 at 9.36.52 AM.png

 

merge后就可以在主仓库看到了,如下.
Screen Shot 2013-04-29 at 9.38.14 AM.png

 

至此,整个协作过程完成。

 

eoe.cn客户端开源

 

原文地址: http://my.eoe.cn/iceskysl/archive/3195.html

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics