├── .gitignore
├── preview.png
├── source
├── images
│ ├── merge.png
│ ├── rebase.png
│ ├── file_status.png
│ ├── master_branch.png
│ ├── after_rebase_onto.png
│ ├── merge-without-ff.png
│ ├── rebase_feature_a.png
│ ├── rebase_feature_b.png
│ ├── before_rebase_onto.png
│ ├── git-branching-model.png
│ └── GitLab
│ │ ├── create_project1.png
│ │ ├── create_project2.png
│ │ ├── create_project3.png
│ │ ├── import_pubkey1.png
│ │ ├── import_pubkey2.png
│ │ ├── public_access.png
│ │ └── gitlab_project_tree.png
├── installation.rst
├── index.rst
├── conflict.rst
├── references.rst
├── gitlab.rst
├── gitlabworkflow.rst
├── other.rst
├── tagging.rst
├── branchingmodel.rst
├── configurations.rst
├── conf.py
├── rebase.rst
└── commands.rst
├── README.md
├── requirements.txt
├── Makefile
└── make.bat
/.gitignore:
--------------------------------------------------------------------------------
1 | build/*
2 |
--------------------------------------------------------------------------------
/preview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spitfire-sidra/git-tutorial/HEAD/preview.png
--------------------------------------------------------------------------------
/source/images/merge.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spitfire-sidra/git-tutorial/HEAD/source/images/merge.png
--------------------------------------------------------------------------------
/source/images/rebase.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spitfire-sidra/git-tutorial/HEAD/source/images/rebase.png
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | **本系列文章以移至 [https://myapollo.com.tw/series/git-tutorial](https://myapollo.com.tw/series/git-tutorial)**
2 |
--------------------------------------------------------------------------------
/source/images/file_status.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spitfire-sidra/git-tutorial/HEAD/source/images/file_status.png
--------------------------------------------------------------------------------
/source/images/master_branch.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spitfire-sidra/git-tutorial/HEAD/source/images/master_branch.png
--------------------------------------------------------------------------------
/source/images/after_rebase_onto.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spitfire-sidra/git-tutorial/HEAD/source/images/after_rebase_onto.png
--------------------------------------------------------------------------------
/source/images/merge-without-ff.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spitfire-sidra/git-tutorial/HEAD/source/images/merge-without-ff.png
--------------------------------------------------------------------------------
/source/images/rebase_feature_a.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spitfire-sidra/git-tutorial/HEAD/source/images/rebase_feature_a.png
--------------------------------------------------------------------------------
/source/images/rebase_feature_b.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spitfire-sidra/git-tutorial/HEAD/source/images/rebase_feature_b.png
--------------------------------------------------------------------------------
/source/images/before_rebase_onto.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spitfire-sidra/git-tutorial/HEAD/source/images/before_rebase_onto.png
--------------------------------------------------------------------------------
/source/images/git-branching-model.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spitfire-sidra/git-tutorial/HEAD/source/images/git-branching-model.png
--------------------------------------------------------------------------------
/source/images/GitLab/create_project1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spitfire-sidra/git-tutorial/HEAD/source/images/GitLab/create_project1.png
--------------------------------------------------------------------------------
/source/images/GitLab/create_project2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spitfire-sidra/git-tutorial/HEAD/source/images/GitLab/create_project2.png
--------------------------------------------------------------------------------
/source/images/GitLab/create_project3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spitfire-sidra/git-tutorial/HEAD/source/images/GitLab/create_project3.png
--------------------------------------------------------------------------------
/source/images/GitLab/import_pubkey1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spitfire-sidra/git-tutorial/HEAD/source/images/GitLab/import_pubkey1.png
--------------------------------------------------------------------------------
/source/images/GitLab/import_pubkey2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spitfire-sidra/git-tutorial/HEAD/source/images/GitLab/import_pubkey2.png
--------------------------------------------------------------------------------
/source/images/GitLab/public_access.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spitfire-sidra/git-tutorial/HEAD/source/images/GitLab/public_access.png
--------------------------------------------------------------------------------
/source/images/GitLab/gitlab_project_tree.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spitfire-sidra/git-tutorial/HEAD/source/images/GitLab/gitlab_project_tree.png
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | Jinja2==2.7.2
2 | MarkupSafe==0.23
3 | Pygments==1.6
4 | Sphinx==1.2.2
5 | docutils==0.11
6 | sphinx-rtd-theme==0.1.6
7 | wsgiref==0.1.2
8 |
--------------------------------------------------------------------------------
/source/installation.rst:
--------------------------------------------------------------------------------
1 | 安裝說明
2 | =========
3 |
4 | 由於目前Git, GitLab 已經是十分成熟的工具與系統,因此相關安裝說明請自行參閱以下連結。
5 |
6 | * `Git 官方網站 `_
7 | * `GitLab 官方網站 `_
8 |
9 | 此外,GitLab官方目前僅於Debian及Ubuntu系統環境內進行開發測試,因此推薦使用Debian或Ubuntu安裝GitLab。
10 |
--------------------------------------------------------------------------------
/source/index.rst:
--------------------------------------------------------------------------------
1 | .. GitWorkflows documentation master file, created by
2 | sphinx-quickstart on Tue Jul 23 15:21:26 2013.
3 | You can adapt this file completely to your liking, but it should at least
4 | contain the root `toctree` directive.
5 |
6 | Practical guide for git users
7 | =============================================
8 |
9 | 本文件旨於教導使用者各種操作 Git 及 GitLab 的實務技巧,從基礎指令到分支策略皆有詳細介紹。希望透過此文件學習,能提高團隊協作開發之能力。
10 |
11 | Contents:
12 |
13 | .. toctree::
14 | :maxdepth: 2
15 |
16 | installation
17 | configurations
18 | commands
19 | branchingmodel
20 | conflict
21 | rebase
22 | tagging
23 | gitlab
24 | gitlabworkflow
25 | other
26 | references
27 |
--------------------------------------------------------------------------------
/source/conflict.rst:
--------------------------------------------------------------------------------
1 | 實戰版本衝突 (Dealing with Conflict)
2 | ==========================================
3 |
4 | 多人的開發團隊在實作各種不同的功能時,版本衝突是肯定會遇到的一種情況,除了慢慢修正一個接一個 Conflict 的選擇之外,以下陳述在幾種情況下可以省時費力的解決方法。
5 |
6 | ============================
7 | --theirs, --ours
8 | ============================
9 |
10 | 在十分確定衝突的版本必須以對方的版本為準時,可以使用以下指令: ::
11 |
12 | $ git checkout --theirs
13 |
14 | 上述的指令顧名思義就是 **把有衝突的檔案還原到對方的版本** 。
15 |
16 | 反之,如果要以我們自己的版本為準時,就可以改用 ``--ours`` : ::
17 |
18 | $ git checkout --ours
19 |
20 | ===================================
21 | 以遠端分支為準,解決版本衝突
22 | ===================================
23 |
24 | 此外,在 pull remote branch 遇到版本衝突時,如果在十分確定以遠端分支為準時,可以使用以下指令: ::
25 |
26 | $ git checkout origin/master
27 |
28 | 上述的指令就是將本地有衝突的檔案,還原到遠端 ``origin/master`` 分支的版本。
29 |
--------------------------------------------------------------------------------
/source/references.rst:
--------------------------------------------------------------------------------
1 | 參考資料
2 | =========
3 |
4 | #. `Git Documentation `_ , http://git-scm.com/documentation
5 | #. `A successful Git branching model `_ , http://nvie.com/posts/a-successful-git-branching-model/
6 | #. `GitHub Ignoring files `_ , https://help.github.com/articles/ignoring-files
7 | #. `GitLab `_ , http://gitlab.org/
8 | #. `Handy Git tips to stop you getting fired `_ , http://blog.apiaxle.com/post/handy-git-tips-to-stop-you-getting-fired/
9 | #. `Must Have Git Aliases: Advanced Examples `_ , http://durdn.com/blog/2012/11/22/must-have-git-aliases-advanced-examples/
10 |
--------------------------------------------------------------------------------
/source/gitlab.rst:
--------------------------------------------------------------------------------
1 | GitLab介紹
2 | ==========
3 |
4 | 目前最流行的線上Git專案管理系統可以說是非 `GitHub`_ 莫屬,對於一般OpenSource的專案選擇使用GitHub做為線上Git專案管理系統即可,也免收任何費用。但對於組織內部所開發的非OpenSource的專案而言,選擇使用GitHub不僅需要付費,保密性也有相當的顧慮。
5 |
6 | 若組織亦有上述的顧慮,可以選擇替代方案-`GitLab`_ !
7 |
8 | .. _GitHub: https://github.com/
9 |
10 | .. _GitLab: http://gitlab.org/
11 |
12 | =========================================
13 | Self hosted Git management software
14 | =========================================
15 |
16 | 事實上,若形容GitLab就是能夠hosting在組織內部網路的GitHub一點也不為過,因為其介面、功能都與GitHub十分神似,有使用GitHub經驗的開發者也能夠很快速上手。
17 |
18 | .. figure:: images/GitLab/gitlab_project_tree.png
19 | :align: center
20 | :width: 700px
21 |
22 | GitLab介面
23 |
24 | 而目前GitLab已整合了以下功能:
25 |
26 | #. Repository access
27 | #. Administration
28 | #. Issues
29 | #. Forks
30 | #. Code review
31 | #. Wiki
32 | #. Merge Requests
33 | #. Web Editor
34 |
35 | 如果有興趣的人也可以試試線上Demo版, `線上Demo連結`_ 。
36 |
37 | .. _線上Demo連結: http://demo.gitlab.com/users/sign_in
38 |
--------------------------------------------------------------------------------
/source/gitlabworkflow.rst:
--------------------------------------------------------------------------------
1 | GitLab工作流程
2 | ==============
3 |
4 | GitLab的工作流程其實與前述所提到的多人合作開發模式相差無幾。
5 |
6 | 以下是直接引述GitLab所提供之 GitLab Workflow :
7 |
8 | #. Clone project ::
9 |
10 | $ git clone git@example.com:project-name.git
11 |
12 | #. Create branch with your feature ::
13 |
14 | $ git checkout -b $feature_name
15 |
16 | #. Write code. Commit changes ::
17 |
18 | $ git commit -am "My feature is ready"
19 |
20 | #. Push your branch to GitLab ::
21 |
22 | $ git push origin $feature_name
23 |
24 | #. Review your code on Commits page
25 | #. Create a merge request
26 | #. Your team lead will review code & merge it to main branch
27 |
28 | 事實上,就這麼簡單。
29 |
30 | 以下主要補充使用GitLab需要注意的地方。
31 |
32 | ---------------------------
33 | 建立新專案
34 | ---------------------------
35 |
36 | #. 介面操作1,新增專案
37 |
38 | .. figure:: images/GitLab/create_project1.png
39 | :width: 600px
40 | :align: center
41 |
42 | #. 介面操作2,輸入專案名稱
43 |
44 | .. figure:: images/GitLab/create_project2.png
45 | :width: 600px
46 | :align: center
47 |
48 | #. 介面操作3,新增完成(紅框部份需修改)
49 |
50 | .. figure:: images/GitLab/create_project3.png
51 | :width: 600px
52 | :align: center
53 |
54 | 完成上述3個步驟之後,其實只是在資料庫中建立專案的資料而已,並非在GitLab的檔案系統內建立一個新的專案資料夾,因此GitLab也分別針對全新專案及既有專案兩種情況,提供了一些指令說明如何建立專案資料夾。
55 |
56 | * 建立新儲存庫 ::
57 |
58 | mkdir myfirstproject
59 | cd myfirstproject
60 | git init
61 | touch README
62 | git add README
63 | git commit -m 'first commit'
64 | git remote add origin git@10.2.0.15:your_account/myfirstproject.git
65 | git push -u origin master
66 |
67 | * 匯入既有專案 ::
68 |
69 | cd existing_git_repo
70 | git remote add origin git@10.2.0.15:your_account/myfirstproject.git
71 | git push -u origin master
72 |
73 | 上述指令若GitLab安裝過程無誤,是可以良好運作的,如有任何問題,大多是網路環境(GitLab Server裝於VM內或使用NAT等原因),這些情況就得更改上述指令才能運作。
74 |
75 | ----------------
76 | 匯入公鑰
77 | ----------------
78 |
79 | #. 介面操作1
80 |
81 | .. figure:: images/GitLab/import_pubkey1.png
82 | :align: center
83 | :width: 600px
84 |
85 | #. 介面操作2
86 |
87 | .. figure:: images/GitLab/import_pubkey2.png
88 | :align: center
89 | :width: 600px
90 |
91 | ----------------
92 | 開放專案
93 | ----------------
94 |
95 | 預設的專案是不開放的(private),所以是無法被其他人(除了Team, Group成員之外)知道這個專案的存在。如果想開放專案給所有人看到,請參照以下操作。
96 |
97 | .. figure:: images/GitLab/public_access.png
98 | :align: center
99 | :width: 600px
100 |
--------------------------------------------------------------------------------
/source/other.rst:
--------------------------------------------------------------------------------
1 | 其他
2 | ==============
3 |
4 |
5 | ========================
6 | git archive 打包程式
7 | ========================
8 |
9 | 有時候我們會需要把整個程式碼打包成一個壓縮檔,同時把裡面的 ``.git`` 資料夾所儲存的版本控制歷程給移除,可以用以下指令進行打包: ::
10 |
11 | $ git archive --format= --output=