Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.
自由軟體鑄造場作業暨智財權說明會 
版本控制系統與科技部專案(以Git為例) 
中研院資訊創新科技研究中心 
自由軟體鑄造場蘇展 
Oct. 6
Code Hosting Sites 
1
Johnson J. Su 
Linkedin:https://www.linkedin.com/in/jansu 
E-mail:johnsonsu@iis.sinica.edu.tw 
TEL:(02) 2788-3799 ext. 147...
Git版本控制教學 
科技部專案操作與資源表列 
Topics 
3
SAME ISSUES! 
4
SAME ISSUES! Collaboration Issues! 
5
YOU NEED VCS 
6
GitBasic 
Topics 
GitWorkflow 
GitHub Flow 
7
GitBasic 
Topic 
8
What is Git? 
GitBasic 
9
Git is an open source, distributed version control system designed for speed and efficiency 
GitBasic 
10
Gitis an open source, distributed version control system designed for speed and efficiency 
GitBasic 
11
Gitis an open source, distributedversion control system designed for speed and efficiency 
GitBasic 
12
GitBasic 
13
GitBasic 
14
GitBasic 
15
Fully Distributed 
GitBasic 
16
(almost) everything is local 
GitBasic 
17
which means 
GitBasic 
18
which means 
everything is fast 
GitBasic 
19
which means 
everything is fast 
every clone is a backup 
GitBasic 
20
which means 
everything is fast 
every clone is a backup 
work offline 
GitBasic 
21
No Network Needed 
GitBasic 
22
No Network Needed 
Performing a diff 
GitBasic 
23
No Network Needed 
Performing a diff 
Viewing file history 
GitBasic 
24
No Network Needed 
Performing a diff 
Viewing file history 
Committing changes 
GitBasic 
25
No Network Needed 
Performing a diff 
Viewing file history 
Committing changes 
Merging branches 
Obtaining other revision...
No Network Needed 
Performing a diff 
Viewing file history 
Committing changes 
Merging branches 
Obtaining other revision...
(almost) never removes data 
GitBasic 
29
Compare with svn… 
GitBasic 
30
Snapshots, not Patches 
GitBasic 
31
File Based 
Delta Storage 
GitBasic 
32
First… 
Let’s make an example of svn 
GitBasic 
33
This is Johnson Su’s excellent project. 
Licensed under GPL. 
README.txt 
#include<stdio.h> 
hello.c 
intmain(void){ 
prin...
This is Johnson Su’s excellent project. 
Licensed under GPL. 
README.txt 
#include<stdio.h> 
hello.c 
intmain(void){ 
prin...
This is Johnson Su’s excellent project. 
Licensed under GPL. 
README.txt 
#include<stdio.h> 
hello.c 
intmain(void){ 
prin...
This is Johnson Su’s excellent project. 
Licensed under GPL. 
README.txt 
#include<stdio.h> 
hello.c 
intmain(void){ 
prin...
This is Johnson Su’s excellent project. 
Licensed under GPL. 
README.txt 
#include<stdio.h> 
hello.c 
intmain(void){ 
prin...
This is Johnson Su’s excellent project. 
Licensed under GPL. 
README.txt 
#include<stdio.h> 
hello.c 
intmain(void){ 
prin...
This is Johnson Su’s excellent project. 
Licensed under GPL. 
README.txt 
#include<stdio.h> 
jello.c 
intmain(void){ 
prin...
This is Johnson Su’s excellent project. 
Licensed under GPL. 
README.txt 
#include<stdio.h> 
jello.c 
intmain(void){ 
prin...
This is Johnson Su’s jelloproject. 
Licensed under GPL. 
README.txt 
#include<stdio.h> 
jello.c 
intmain(void){ 
printf(“J...
This is Johnson Su’s jelloproject. 
Licensed under GPL. 
README.txt 
#include<stdio.h> 
jello.c 
intmain(void){ 
printf(“J...
This is Johnson Su’s jelloproject. 
Licensed under GPL. 
README.txt 
#include<stdio.h> 
jello.c 
intmain(void){ 
printf(“J...
This is Johnson Su’s jelloproject. 
Licensed under GPL. 
README.txt 
#include<stdio.h> 
jello.c 
intmain(void){ 
printf(“J...
GitSnapshots 
GitBasic 
46
This is Johnson Su’s excellent project. 
Licensed under GPL. 
README.txt 
#include<stdio.h> 
hello.c 
intmain(void){ 
prin...
This is Johnson Su’s excellent project. 
Licensed under GPL. 
README.txt 
#include<stdio.h> 
hello.c 
intmain(void){ 
prin...
This is Johnson Su’s excellent project. 
Licensed under GPL. 
README.txt 
#include<stdio.h> 
hello.c 
intmain(void){ 
prin...
This is Johnson Su’s excellent project. 
Licensed under GPL. 
README.txt 
#include<stdio.h> 
hello.c 
intmain(void){ 
prin...
This is Johnson Su’s excellent project. 
Licensed under GPL. 
README.txt 
#include<stdio.h> 
hello.c 
intmain(void){ 
prin...
This is Johnson Su’s excellent project. 
Licensed under GPL. 
README.txt 
#include<stdio.h> 
hello.c 
intmain(void){ 
prin...
This is Johnson Su’s excellent project. 
Licensed under GPL. 
README.txt 
#include<stdio.h> 
hello.c 
intmain(void){ 
prin...
This is Johnson Su’s excellent project. 
Licensed under GPL. 
README.txt 
#include<stdio.h> 
hello.c 
intmain(void){ 
prin...
This is Johnson Su’s excellent project. 
Licensed under GPL. 
README.txt 
#include<stdio.h> 
hello.c 
intmain(void){ 
prin...
This is Johnson Su’s excellent project. 
Licensed under GPL. 
README.txt 
#include<stdio.h> 
hello.c 
intmain(void){ 
prin...
This is Johnson Su’s excellent project. 
Licensed under GPL. 
README.txt 
#include<stdio.h> 
hello.c 
intmain(void){ 
prin...
This is Johnson Su’s excellent project. 
Licensed under GPL. 
README.txt 
#include<stdio.h> 
jello.c 
intmain(void){ 
prin...
This is Johnson Su’s excellent project. 
Licensed under GPL. 
README.txt 
#include<stdio.h> 
jello.c 
intmain(void){ 
prin...
This is Johnson Su’s excellent project. 
Licensed under GPL. 
README.txt 
#include<stdio.h> 
jello.c 
intmain(void){ 
prin...
This is Johnson Su’s excellent project. 
Licensed under GPL. 
README.txt 
#include<stdio.h> 
jello.c 
intmain(void){ 
prin...
This is Johnson Su’s excellent project. 
Licensed under GPL. 
#include<stdio.h> 
intmain(void){ 
printf(“Hellon”); 
return...
This is Johnson Su’s excellent project. 
Licensed under GPL. 
#include<stdio.h> 
intmain(void){ 
printf(“Hellon”); 
return...
This is Johnson Su’s excellent project. 
Licensed under GPL. 
#include<stdio.h> 
intmain(void){ 
printf(“Hellon”); 
return...
This is Johnson Su’s excellent project. 
Licensed under GPL. 
#include<stdio.h> 
intmain(void){ 
printf(“Hellon”); 
return...
This is Johnson Su’s excellent project. 
Licensed under GPL. 
#include<stdio.h> 
intmain(void){ 
printf(“Hellon”); 
return...
67 
GitBasic
68 
GitBasic 
Gitcommands 
(Live demo)
Beforewe start 
to use Gitrepository…… 
69 
GitBasic
http://git-scm.com/ 
GitInstallation 
70 
GitBasic
$ gitconfig--global user.name “Johnson J. Su” 
$ gitconfig--global user.email“johnsonsu@iis.sinica.edu.tw” 
Setting Up Git...
Let’s start using Git 
first… 
Create or Clone a Gitrepository 
72 
GitBasic
Two way to get Gitrepository… 
$ gitclone https://example.com/example.git 
$ mkdirproject 
$ cd project 
$ gitinit 
gitclo...
74 
GitBasic 
Johnson creates README.txt file 
Add file to staging area 
Commit changes 
Johnson modifies README.txt file ...
Untracked 
Unmodified 
Modified 
Staged 
initial 
gitinit 
File Status Lifecycle 
75 
GitBasic
$ mkdirproject 
$ cd project 
$ touch README.txt 
$ gitinit 
$ tree -a 
Use the following commands: 
76 
GitBasic
Untracked 
Unmodified 
Modified 
Staged 
initial 
gitinit 
add the file 
1.gitadd filename 
2.gitcommit 
File Status Lifec...
$ gitadd . 
$ gitstatus 
$ gitcommit –m “Initial commit” 
Use the following commands: 
78 
GitBasic
Untracked 
Unmodified 
Modified 
Staged 
initial 
gitinit 
add the file 
add/edit the file 
gitadd filename 
File Status L...
README.txt 
Use the following commands: 
80 
GitBasic
$ vim README.txt 
Use the following commands: 
This is Johnson Su’s excellentproject. 
Licensed under GPL. 
README.txt 
81...
$ vim README.txt 
$ touch hello.c 
Use the following commands: 
This is Johnson Su’s excellentproject. 
Licensed under GPL...
$ vim README.txt 
$ touch hello.c 
$ vim hello.c 
Use the following commands: 
This is Johnson Su’s excellentproject. 
Lic...
$ vim README.txt 
$ touch hello.c 
$ vim hello.c 
Use the following commands: 
This is Johnson Su’s excellentproject. 
Lic...
Untracked 
Unmodified 
Modified 
Staged 
initial 
gitinit 
add the file 
add/edit the file 
stage the file 
gitadd filenam...
$ gitadd . 
$ gitstatus 
$ gitcommit –m “modify README.txt and add hello.cfile” 
Use the following commands: 
The commit m...
Untracked 
Unmodified 
Modified 
Staged 
initial 
gitinit 
add the file 
add/edit the file 
stage the file 
gitadd filenam...
Untracked 
Unmodified 
Modified 
Staged 
initial 
gitinit 
add the file 
add/edit the file 
stage the file 
gitadd filenam...
$ gitstatus 
$ gitrmhello.c 
$ gitstatus 
Use the following commands: 
89 
GitBasic
90 
GitBasic
Untracked 
Unmodified 
Modified 
Staged 
initial 
gitinit 
add the file 
add/edit the file 
stage the file 
gitadd filenam...
$ vim hello.c 
Use the following commands: 
#include<stdio.h> 
hello.c 
intmain(void){ 
printf(“Hellon”); 
return 0; 
} 
i...
$ vim hello.c 
$ gitcheckout hello.c 
Use the following commands: 
#include<stdio.h> 
hello.c 
intmain(void){ 
printf(“Hel...
Untracked 
Unmodified 
Modified 
Staged 
initial 
gitinit 
add the file 
add/edit the file 
stage the file 
gitadd filenam...
Use the following commands: 
#include<stdio.h> 
hello.c 
intmain(void){ 
printf(“Hellon”); 
return 0; 
} 
intmain(void){ 
...
Use the following commands: 
#include<stdio.h> 
hello.c 
intmain(void){ 
printf(“Hellon”); 
return 0; 
} 
intmain(void){ 
...
Use the following commands: 
#include<stdio.h> 
hello.c 
intmain(void){ 
printf(“Hellon”); 
return 0; 
} 
intmain(void){ 
...
$ vim hello.c 
$ gitadd hello.c 
$ gitreset HEAD hello.c 
$ gitcheckout hello.c 
Use the following commands: 
#include<std...
$ gitadd <list of files> 
Different ways to add files to staging area 
99 
GitBasic 
$ gitadd *.txt 
$ gitadd main/*.txt 
...
Specifies intentionally untracked files to ignore. 
100 
GitBasic 
Useful Options 
“.gitignore”
101 
GitBasic
gitlog 
If you want to review all the commits… 
102 
GitBasic
$ gitlog 
commit 71358d83b0249362851174566042d2f3a412f985 
Author: Johnson <johnsonsu@iis.sinica.edu.tw> 
Date: Thu Jul 3 ...
gitdiff 
If you want to review some differences 
since last commit 
104 
GitBasic
If you want to modify last commit message…? 
105 
GitBasic
$ gitcommit –m “!@#$^%&*()_” 
$ gitlog 
$ gitreset --soft HEAD^ 
$ gitlog 
$ gitcommit –m “add new file xxx” 
$ gitlog 
Us...
$ gitcommit –m “!@#$^%&*()_” 
$ gitlog 
$ gitcommit -amend 
$ gitlog 
Use the following commands: 
add new file xxx 
107 
...
$ gitcommit –m “!@#$^%&*()_” 
$ gitlog 
$ gitcommit -amend 
$ gitlog 
Use the following commands: 
add new file xxx 
108 
...
$ gitreset ––soft HEAD^ 
Different ways to add files to staging area 
109 
GitBasic 
$ gitreset ––hard HEAD^ 
$ gitreset –...
How to share your Gitrepository 
110 
GitBasic
111 
Remote Repository 
Master 
$ gitpush origin master 
GitBasic 
Hosted 
•GitHub 
•OpenFoundry 
•SourceForge 
•Google Co...
112 
Remote Repository 
Master 
$ gitpull 
GitBasic 
$ gitpush origin master
113 
GitBasic
114 
GitBasic
115 
GitBasic
GitBasic 
$ gitremote add origin https://github.com/OpenFoundry/MOST_TRY_GIT.git 
Adding a Remote 
116
GitBasic 
$ gitpush –u origin master 
Pushing to Remote 
117
118 
GitBasic
119 
GitBasic
120 
GitBasic 
$ gitpull 
To pull changes down from the remote
121 
GitBasic 
origin 
master 
production 
test 
Having multiple remotes
122 
GitBasic 
$ gitremote add <name> <address> 
Working with remotes 
$ gitpush –u <name> <branch> 
$ gitremote rm<name> ...
123 
GitBasic
$ gitreset ––soft HEAD^ 
Don’t do these after you push 
124 
GitBasic 
$ gitreset ––hard HEAD^ 
$ gitreset ––hard HEAD^^ 
...
$ gitreset ––soft HEAD^ 
Don’t do these after you push 
125 
GitBasic 
$ gitreset ––hard HEAD^ 
$ gitreset ––hard HEAD^^ 
...
Topic 
GitWorkflow 
126
GitWorkflow 
127 
Remote Repository 
Johnson 
Vince 
Joseph
GitWorkflow 
128
GitWorkflow 
129 
$ gitclone https://github.com/OpenFoundry/MOST_TRY_GIT.git 
Cloning the Repository
GitWorkflow 
130 
master 
Branching out 
dog
GitWorkflow 
131 
master 
Switch to dog branch and working on it 
dog
GitWorkflow 
132 
master 
List of dog branch 
dog
GitWorkflow 
133 
master 
Back to master branch 
dog
GitWorkflow 
134 
master 
Merge from dog 
dog 
HEAD
GitWorkflow 
135 
Using Command: gitlog 
master 
dog 
HEAD
GitWorkflow 
136 
Branch Clean up 
master 
dog 
HEAD
GitWorkflow 
137 
Back to dog branch 
master 
dog 
HEAD
Topic 
GitWorkflow 
138
Topic 
139 
gittag 
Like most VCSs, Githas the ability to tag specific points in history as being important.
140 
GitBasic 
$ gittag 
v0.0.1 
v0.0.2 
Tagging 
$ gittag –a v0.0.3 –m “version 0.0.3” 
$ gitcheckout v0.0.1 
List all ta...
Topic 
GitWorkflow 
141
Topic 
142
Topic 
143
Topic 
144
Topic 
145
Topic 
GitHub Flow 
146
Topic 
GitHub Flow 
147
Topic 
GitHub Flow 
148
Topic 
GitHub Flow 
149
Topic 
GitHub Flow 
150
151 
More… 
•這份投影片大部分的內容都出至於SCOTT CHACON釋出的 文件與Code School Real Git的簡報,若想了解更多Git相關 技術,以下推薦您參考使用。 
•英文推薦 
•Pro Git 
•GitRef...
Git版本控制教學 
科技部專案操作與資源表列 
Topics 
152
科技部專案 
要做的事 
科技部專案操作與資源表列 
153
Code Hosting Sites 
154
主要分為兩種 1.國科會專案(doc or pdf) 成果報告書 需求分析 測試文件 
2.規畫釋出(unlimited) 
原始程式碼 
安裝文件 
使用手冊 
上傳檔案類別 
155
科技部專案 
156
上傳文件 
157 
請依規定時程上傳文件
上傳文件 
158 
請注意上傳文件的檔案格式
主要分為兩種 
1.國科會專案(doc or pdf) 
成果報告書 
需求分析 
測試文件 2.規畫釋出(unlimited) 原始程式碼 安裝文件 使用手冊 
上傳檔案類別 
159
放上檔案供人下載 
安裝程式檔、安裝使用手冊 
README、LICENSE、INSTALLATION 
安裝使用手冊 
160
FTP一般檔案上傳 
161
FTP一般檔案上傳 
162
FTP一般檔案上傳 
163
FTP一般檔案上傳 
164
FTP一般檔案上傳 
165
FTP一般檔案上傳 
166
FTP一般檔案上傳 
167
FTP一般檔案上傳 
168
FTP一般檔案上傳 
169
FTP一般檔案上傳 
170
FTP一般檔案上傳 
171
FTP一般檔案上傳 
172
FTP一般檔案上傳 
173
174 
完成釋出
175 
完成釋出
FTP大檔案上傳 
大型檔案請採用FTP上傳! 
參考說明 
176
以上、 
完成一個規畫釋出的上傳流程 
177
線上協助 
參考此處 
178
Johnson J. Su 
Linkedin:https://www.linkedin.com/in/jansu 
E-mail:johnsonsu@iis.sinica.edu.tw 
TEL:(02) 2788-3799 ext. 147...
Q & A 
180
Prochain SlideShare
Chargement dans…5
×

MOST_OpenFoundry_version control system_Git

205 vues

Publié le

Give a talk about using Git.

Publié dans : Ingénierie
  • Soyez le premier à commenter

MOST_OpenFoundry_version control system_Git

  1. 1. 自由軟體鑄造場作業暨智財權說明會 版本控制系統與科技部專案(以Git為例) 中研院資訊創新科技研究中心 自由軟體鑄造場蘇展 Oct. 6
  2. 2. Code Hosting Sites 1
  3. 3. Johnson J. Su Linkedin:https://www.linkedin.com/in/jansu E-mail:johnsonsu@iis.sinica.edu.tw TEL:(02) 2788-3799 ext. 1478 2
  4. 4. Git版本控制教學 科技部專案操作與資源表列 Topics 3
  5. 5. SAME ISSUES! 4
  6. 6. SAME ISSUES! Collaboration Issues! 5
  7. 7. YOU NEED VCS 6
  8. 8. GitBasic Topics GitWorkflow GitHub Flow 7
  9. 9. GitBasic Topic 8
  10. 10. What is Git? GitBasic 9
  11. 11. Git is an open source, distributed version control system designed for speed and efficiency GitBasic 10
  12. 12. Gitis an open source, distributed version control system designed for speed and efficiency GitBasic 11
  13. 13. Gitis an open source, distributedversion control system designed for speed and efficiency GitBasic 12
  14. 14. GitBasic 13
  15. 15. GitBasic 14
  16. 16. GitBasic 15
  17. 17. Fully Distributed GitBasic 16
  18. 18. (almost) everything is local GitBasic 17
  19. 19. which means GitBasic 18
  20. 20. which means everything is fast GitBasic 19
  21. 21. which means everything is fast every clone is a backup GitBasic 20
  22. 22. which means everything is fast every clone is a backup work offline GitBasic 21
  23. 23. No Network Needed GitBasic 22
  24. 24. No Network Needed Performing a diff GitBasic 23
  25. 25. No Network Needed Performing a diff Viewing file history GitBasic 24
  26. 26. No Network Needed Performing a diff Viewing file history Committing changes GitBasic 25
  27. 27. No Network Needed Performing a diff Viewing file history Committing changes Merging branches Obtaining other revisions of a file GitBasic 26
  28. 28. No Network Needed Performing a diff Viewing file history Committing changes Merging branches Obtaining other revisions of a file Switching branches GitBasic 27
  29. 29. (almost) never removes data GitBasic 29
  30. 30. Compare with svn… GitBasic 30
  31. 31. Snapshots, not Patches GitBasic 31
  32. 32. File Based Delta Storage GitBasic 32
  33. 33. First… Let’s make an example of svn GitBasic 33
  34. 34. This is Johnson Su’s excellent project. Licensed under GPL. README.txt #include<stdio.h> hello.c intmain(void){ printf(“Hellon”); return 0; } 34
  35. 35. This is Johnson Su’s excellent project. Licensed under GPL. README.txt #include<stdio.h> hello.c intmain(void){ printf(“Hellon”); return 0; } README.txt hello.c Commit A This is Johnson Su’s excellent project. Licensed under GPL. #include<stdio.h> intmain(void){ printf(“Hellon”); return 0; } . 35
  36. 36. This is Johnson Su’s excellent project. Licensed under GPL. README.txt #include<stdio.h> hello.c intmain(void){ printf(“Hellon”); return 0; } README.txt hello.c Commit A This is Johnson Su’s excellent project. Licensed under GPL. #include<stdio.h> intmain(void){ printf(“Hellon”); return 0; } . 36
  37. 37. This is Johnson Su’s excellent project. Licensed under GPL. README.txt #include<stdio.h> hello.c intmain(void){ printf(“Jellon”); return 0; } README.txt hello.c Commit A This is Johnson Su’s excellent project. Licensed under GPL. #include<stdio.h> intmain(void){ printf(“Hellon”); return 0; } . 37
  38. 38. This is Johnson Su’s excellent project. Licensed under GPL. README.txt #include<stdio.h> hello.c intmain(void){ printf(“Jellon”); return 0; } Commit B -printf("Hellon"); + printf(“Jellon"); README.txt hello.c Commit A This is Johnson Su’s excellent project. Licensed under GPL. #include<stdio.h> intmain(void){ printf(“Hellon”); return 0; } . 38
  39. 39. This is Johnson Su’s excellent project. Licensed under GPL. README.txt #include<stdio.h> hello.c intmain(void){ printf(“Jellon”); return 0; } Commit B -printf("Hellon"); + printf(“Jellon"); README.txt hello.c Commit A This is Johnson Su’s excellent project. Licensed under GPL. #include<stdio.h> intmain(void){ printf(“Hellon”); return 0; } . 39
  40. 40. This is Johnson Su’s excellent project. Licensed under GPL. README.txt #include<stdio.h> jello.c intmain(void){ printf(“Jellon”); return 0; } Commit B -printf("Hellon"); + printf(“Jellon"); README.txt hello.c Commit A This is Johnson Su’s excellent project. Licensed under GPL. #include<stdio.h> intmain(void){ printf(“Hellon”); return 0; } . 40
  41. 41. This is Johnson Su’s excellent project. Licensed under GPL. README.txt #include<stdio.h> jello.c intmain(void){ printf(“Jellon”); return 0; } Commit B -printf("Hellon"); + printf(“Jellon"); README.txt hello.c Commit A This is Johnson Su’s excellent project. Licensed under GPL. #include<stdio.h> intmain(void){ printf(“Hellon”); return 0; } . jello.c (rename) Commit C 41
  42. 42. This is Johnson Su’s jelloproject. Licensed under GPL. README.txt #include<stdio.h> jello.c intmain(void){ printf(“Jellon”); return 0; } Commit B -printf("Hellon"); + printf(“Jellon"); README.txt hello.c Commit A This is Johnson Su’s excellent project. Licensed under GPL. #include<stdio.h> intmain(void){ printf(“Hellon”); return 0; } . jello.c (rename) Commit C 42
  43. 43. This is Johnson Su’s jelloproject. Licensed under GPL. README.txt #include<stdio.h> jello.c intmain(void){ printf(“Jellon”); return 0; } #include<stdio.h> hello.c intmain(void){ printf(“Jellon”); return 0; } Commit B -printf("Hellon"); + printf(“Jellon"); README.txt hello.c Commit A This is Johnson Su’s excellent project. Licensed under GPL. #include<stdio.h> intmain(void){ printf(“Hellon”); return 0; } . jello.c (rename) Commit C 43
  44. 44. This is Johnson Su’s jelloproject. Licensed under GPL. README.txt #include<stdio.h> jello.c intmain(void){ printf(“Jellon”); return 0; } #include<stdio.h> hello.c intmain(void){ printf(“Jellon”); return 0; } Commit B -printf("Hellon"); + printf(“Jellon"); README.txt hello.c Commit A This is Johnson Su’s excellent project. Licensed under GPL. #include<stdio.h> intmain(void){ printf(“Hellon”); return 0; } . jello.c (rename) Commit C Commit D -excellent + Jello (rename) 44
  45. 45. This is Johnson Su’s jelloproject. Licensed under GPL. README.txt #include<stdio.h> jello.c intmain(void){ printf(“Jellon”); return 0; } #include<stdio.h> hello.c intmain(void){ printf(“Jellon”); return 0; } Commit B -printf("Hellon"); + printf(“Jellon"); README.txt hello.c Commit A This is Johnson Su’s excellent project. Licensed under GPL. #include<stdio.h> intmain(void){ printf(“Hellon”); return 0; } . jello.c (rename) Commit C Commit D -excellent + Jello (rename) 45
  46. 46. GitSnapshots GitBasic 46
  47. 47. This is Johnson Su’s excellent project. Licensed under GPL. README.txt #include<stdio.h> hello.c intmain(void){ printf(“Hellon”); return 0; } 47
  48. 48. This is Johnson Su’s excellent project. Licensed under GPL. README.txt #include<stdio.h> hello.c intmain(void){ printf(“Hellon”); return 0; } This is Johnson Su’s excellent project. Licensed under GPL. #include<stdio.h> intmain(void){ printf(“Hellon”); return 0; } c3d f13 CHECKSUM 48
  49. 49. This is Johnson Su’s excellent project. Licensed under GPL. README.txt #include<stdio.h> hello.c intmain(void){ printf(“Hellon”); return 0; } This is Johnson Su’s excellent project. Licensed under GPL. #include<stdio.h> intmain(void){ printf(“Hellon”); return 0; } c3d f13 CHECKSUM 49
  50. 50. This is Johnson Su’s excellent project. Licensed under GPL. README.txt #include<stdio.h> hello.c intmain(void){ printf(“Hellon”); return 0; } This is Johnson Su’s excellent project. Licensed under GPL. #include<stdio.h> intmain(void){ printf(“Hellon”); return 0; } c3d f13 Commit A c3dREADME.txt f13hello.c 50
  51. 51. This is Johnson Su’s excellent project. Licensed under GPL. README.txt #include<stdio.h> hello.c intmain(void){ printf(“Hellon”); return 0; } This is Johnson Su’s excellent project. Licensed under GPL. #include<stdio.h> intmain(void){ printf(“Hellon”); return 0; } c3d f13 Commit A c3dREADME.txt f13hello.c 51
  52. 52. This is Johnson Su’s excellent project. Licensed under GPL. README.txt #include<stdio.h> hello.c intmain(void){ printf(“Hellon”); return 0; } Commit A c3dREADME.txt f13hello.c This is Johnson Su’s excellent project. Licensed under GPL. #include<stdio.h> intmain(void){ printf(“Hellon”); return 0; } c3d f13 52
  53. 53. This is Johnson Su’s excellent project. Licensed under GPL. README.txt #include<stdio.h> hello.c intmain(void){ printf(“Hellon”); return 0; } Commit A c3dREADME.txt f13hello.c This is Johnson Su’s excellent project. Licensed under GPL. #include<stdio.h> intmain(void){ printf(“Hellon”); return 0; } c3d f13 53
  54. 54. This is Johnson Su’s excellent project. Licensed under GPL. README.txt #include<stdio.h> hello.c intmain(void){ printf(“Jellon”); return 0; } This is Johnson Su’s excellent project. Licensed under GPL. #include<stdio.h> intmain(void){ printf(“Hellon”); return 0; } c3d f13 Commit A c3dREADME.txt f13hello.c 54
  55. 55. This is Johnson Su’s excellent project. Licensed under GPL. README.txt #include<stdio.h> hello.c intmain(void){ printf(“Jellon”); return 0; } This is Johnson Su’s excellent project. Licensed under GPL. #include<stdio.h> intmain(void){ printf(“Hellon”); return 0; } c3d f13 Commit A c3dREADME.txt f13hello.c Commit B c3dREADME.txt 6d4hello.c #include<stdio.h> intmain(void){ printf(“Jellon”); return 0; } 6d4 55
  56. 56. This is Johnson Su’s excellent project. Licensed under GPL. README.txt #include<stdio.h> hello.c intmain(void){ printf(“Jellon”); return 0; } This is Johnson Su’s excellent project. Licensed under GPL. #include<stdio.h> intmain(void){ printf(“Hellon”); return 0; } c3d f13 Commit A c3dREADME.txt f13hello.c Commit B c3dREADME.txt 6d4hello.c #include<stdio.h> intmain(void){ printf(“Jellon”); return 0; } 6d4 56
  57. 57. This is Johnson Su’s excellent project. Licensed under GPL. README.txt #include<stdio.h> hello.c intmain(void){ printf(“Jellon”); return 0; } This is Johnson Su’s excellent project. Licensed under GPL. #include<stdio.h> intmain(void){ printf(“Hellon”); return 0; } c3d f13 Commit A c3dREADME.txt f13hello.c Commit B c3dREADME.txt 6d4hello.c #include<stdio.h> intmain(void){ printf(“Jellon”); return 0; } 6d4 57
  58. 58. This is Johnson Su’s excellent project. Licensed under GPL. README.txt #include<stdio.h> jello.c intmain(void){ printf(“Jellon”); return 0; } This is Johnson Su’s excellent project. Licensed under GPL. #include<stdio.h> intmain(void){ printf(“Hellon”); return 0; } c3d f13 Commit A c3dREADME.txt f13hello.c Commit B c3dREADME.txt 6d4hello.c #include<stdio.h> intmain(void){ printf(“Jellon”); return 0; } 6d4 58
  59. 59. This is Johnson Su’s excellent project. Licensed under GPL. README.txt #include<stdio.h> jello.c intmain(void){ printf(“Jellon”); return 0; } This is Johnson Su’s excellent project. Licensed under GPL. #include<stdio.h> intmain(void){ printf(“Hellon”); return 0; } c3d f13 Commit A c3dREADME.txt f13hello.c Commit B c3dREADME.txt 6d4hello.c #include<stdio.h> intmain(void){ printf(“Jellon”); return 0; } 6d4 Commit C c3dREADME.txt 6d4jello.c 59
  60. 60. This is Johnson Su’s excellent project. Licensed under GPL. README.txt #include<stdio.h> jello.c intmain(void){ printf(“Jellon”); return 0; } This is Johnson Su’s excellent project. Licensed under GPL. #include<stdio.h> intmain(void){ printf(“Hellon”); return 0; } c3d f13 Commit A c3dREADME.txt f13hello.c Commit B c3dREADME.txt 6d4hello.c #include<stdio.h> intmain(void){ printf(“Jellon”); return 0; } 6d4 Commit C c3dREADME.txt 6d4jello.c 60
  61. 61. This is Johnson Su’s excellent project. Licensed under GPL. README.txt #include<stdio.h> jello.c intmain(void){ printf(“Jellon”); return 0; } This is Johnson Su’s excellent project. Licensed under GPL. #include<stdio.h> intmain(void){ printf(“Hellon”); return 0; } c3d f13 Commit A c3dREADME.txt f13hello.c Commit B c3dREADME.txt 6d4hello.c #include<stdio.h> intmain(void){ printf(“Jellon”); return 0; } 6d4 Commit C c3dREADME.txt 6d4jello.c 61
  62. 62. This is Johnson Su’s excellent project. Licensed under GPL. #include<stdio.h> intmain(void){ printf(“Hellon”); return 0; } c3d f13 Commit A c3dREADME.txt f13hello.c Commit B c3dREADME.txt 6d4hello.c #include<stdio.h> intmain(void){ printf(“Jellon”); return 0; } 6d4 Commit C c3dREADME.txt 6d4jello.c This is Johnson Su’s Jelloproject. Licensed under GPL. README.txt #include<stdio.h> jello.c intmain(void){ printf(“Jellon”); return 0; } 62
  63. 63. This is Johnson Su’s excellent project. Licensed under GPL. #include<stdio.h> intmain(void){ printf(“Hellon”); return 0; } c3d f13 Commit A c3dREADME.txt f13hello.c Commit B c3dREADME.txt 6d4hello.c #include<stdio.h> intmain(void){ printf(“Jellon”); return 0; } 6d4 Commit C c3dREADME.txt 6d4jello.c This is Johnson Su’s Jelloproject. Licensed under GPL. README.txt #include<stdio.h> jello.c intmain(void){ printf(“Jellon”); return 0; } #include<stdio.h> hello.c intmain(void){ printf(“Jellon”); return 0; } 63
  64. 64. This is Johnson Su’s excellent project. Licensed under GPL. #include<stdio.h> intmain(void){ printf(“Hellon”); return 0; } c3d f13 Commit A c3dREADME.txt f13hello.c Commit B c3dREADME.txt 6d4hello.c #include<stdio.h> intmain(void){ printf(“Jellon”); return 0; } 6d4 Commit C c3dREADME.txt 6d4jello.c This is Johnson Su’s Jelloproject. Licensed under GPL. README.txt #include<stdio.h> jello.c intmain(void){ printf(“Jellon”); return 0; } #include<stdio.h> hello.c intmain(void){ printf(“Jellon”); return 0; } This is Johnson Su’s Jelloproject. Licensed under GPL. 84f 64
  65. 65. This is Johnson Su’s excellent project. Licensed under GPL. #include<stdio.h> intmain(void){ printf(“Hellon”); return 0; } c3d f13 Commit A c3dREADME.txt f13hello.c Commit B c3dREADME.txt 6d4hello.c #include<stdio.h> intmain(void){ printf(“Jellon”); return 0; } 6d4 Commit C c3dREADME.txt 6d4jello.c This is Johnson Su’s Jelloproject. Licensed under GPL. README.txt #include<stdio.h> jello.c intmain(void){ printf(“Jellon”); return 0; } #include<stdio.h> hello.c intmain(void){ printf(“Jellon”); return 0; } This is Johnson Su’s Jelloproject. Licensed under GPL. 84f Commit D 84fREADME.txt 6d4jello.c 6d4hello.c 65
  66. 66. This is Johnson Su’s excellent project. Licensed under GPL. #include<stdio.h> intmain(void){ printf(“Hellon”); return 0; } c3d f13 Commit A c3dREADME.txt f13hello.c Commit B c3dREADME.txt 6d4hello.c #include<stdio.h> intmain(void){ printf(“Jellon”); return 0; } 6d4 Commit C c3dREADME.txt 6d4jello.c This is Johnson Su’s Jelloproject. Licensed under GPL. README.txt #include<stdio.h> jello.c intmain(void){ printf(“Jellon”); return 0; } #include<stdio.h> hello.c intmain(void){ printf(“Jellon”); return 0; } This is Johnson Su’s Jelloproject. Licensed under GPL. 84f Commit D 84fREADME.txt 6d4jello.c 6d4hello.c 66
  67. 67. 67 GitBasic
  68. 68. 68 GitBasic Gitcommands (Live demo)
  69. 69. Beforewe start to use Gitrepository…… 69 GitBasic
  70. 70. http://git-scm.com/ GitInstallation 70 GitBasic
  71. 71. $ gitconfig--global user.name “Johnson J. Su” $ gitconfig--global user.email“johnsonsu@iis.sinica.edu.tw” Setting Up Git $ gitconfig--global color.uiture 71 GitBasic
  72. 72. Let’s start using Git first… Create or Clone a Gitrepository 72 GitBasic
  73. 73. Two way to get Gitrepository… $ gitclone https://example.com/example.git $ mkdirproject $ cd project $ gitinit gitclone repository from remote server gitinitial a repository in local system 73 GitBasic
  74. 74. 74 GitBasic Johnson creates README.txt file Add file to staging area Commit changes Johnson modifies README.txt file & adds hello.c Add both file to staging area Commit changes
  75. 75. Untracked Unmodified Modified Staged initial gitinit File Status Lifecycle 75 GitBasic
  76. 76. $ mkdirproject $ cd project $ touch README.txt $ gitinit $ tree -a Use the following commands: 76 GitBasic
  77. 77. Untracked Unmodified Modified Staged initial gitinit add the file 1.gitadd filename 2.gitcommit File Status Lifecycle 77 GitBasic
  78. 78. $ gitadd . $ gitstatus $ gitcommit –m “Initial commit” Use the following commands: 78 GitBasic
  79. 79. Untracked Unmodified Modified Staged initial gitinit add the file add/edit the file gitadd filename File Status Lifecycle 79 GitBasic
  80. 80. README.txt Use the following commands: 80 GitBasic
  81. 81. $ vim README.txt Use the following commands: This is Johnson Su’s excellentproject. Licensed under GPL. README.txt 81 GitBasic
  82. 82. $ vim README.txt $ touch hello.c Use the following commands: This is Johnson Su’s excellentproject. Licensed under GPL. README.txt hello.c 82 GitBasic
  83. 83. $ vim README.txt $ touch hello.c $ vim hello.c Use the following commands: This is Johnson Su’s excellentproject. Licensed under GPL. README.txt hello.c 83 GitBasic
  84. 84. $ vim README.txt $ touch hello.c $ vim hello.c Use the following commands: This is Johnson Su’s excellentproject. Licensed under GPL. README.txt #include<stdio.h> hello.c intmain(void){ printf(“Hellon”); return 0; } 84 GitBasic
  85. 85. Untracked Unmodified Modified Staged initial gitinit add the file add/edit the file stage the file gitadd filename gitadd filename File Status Lifecycle 85 GitBasic
  86. 86. $ gitadd . $ gitstatus $ gitcommit –m “modify README.txt and add hello.cfile” Use the following commands: The commit message must be very clear!! (Recommend) 86 GitBasic
  87. 87. Untracked Unmodified Modified Staged initial gitinit add the file add/edit the file stage the file gitadd filename Commit a version gitadd filename gitcommit File Status Lifecycle 87 GitBasic
  88. 88. Untracked Unmodified Modified Staged initial gitinit add the file add/edit the file stage the file gitadd filename Commit a version Remove the file gitadd filename gitcommit gitrmfilename File Status Lifecycle 88 GitBasic
  89. 89. $ gitstatus $ gitrmhello.c $ gitstatus Use the following commands: 89 GitBasic
  90. 90. 90 GitBasic
  91. 91. Untracked Unmodified Modified Staged initial gitinit add the file add/edit the file stage the file gitadd filename Commit a version gitadd filename gitcommit File Status Lifecycle add/edit the file gitcheckout filename 91 GitBasic
  92. 92. $ vim hello.c Use the following commands: #include<stdio.h> hello.c intmain(void){ printf(“Hellon”); return 0; } intmain(void){ printf(“Hellon”); return 0; !@#$%%&*($%@#$%& } 92 GitBasic
  93. 93. $ vim hello.c $ gitcheckout hello.c Use the following commands: #include<stdio.h> hello.c intmain(void){ printf(“Hellon”); return 0; } intmain(void){ printf(“Hellon”); return 0; !@#$%%&*($%@#$%& } #include<stdio.h> hello.c intmain(void){ printf(“Hellon”); return 0; } 93 GitBasic
  94. 94. Untracked Unmodified Modified Staged initial gitinit add the file add/edit the file stage the file gitadd filename Commit a version gitadd filename gitcommit File Status Lifecycle add/edit the file gitreset HEAD filename stage the file gitadd filename 94 GitBasic
  95. 95. Use the following commands: #include<stdio.h> hello.c intmain(void){ printf(“Hellon”); return 0; } intmain(void){ printf(“Hellon”); return 0; !@#$%%&*($%@#$%& } 95 GitBasic $ vim hello.c
  96. 96. Use the following commands: #include<stdio.h> hello.c intmain(void){ printf(“Hellon”); return 0; } intmain(void){ printf(“Hellon”); return 0; !@#$%%&*($%@#$%& } 96 GitBasic $ vim hello.c $ gitadd hello.c
  97. 97. Use the following commands: #include<stdio.h> hello.c intmain(void){ printf(“Hellon”); return 0; } intmain(void){ printf(“Hellon”); return 0; !@#$%%&*($%@#$%& } 97 GitBasic $ vim hello.c $ gitadd hello.c $ gitreset HEAD hello.c
  98. 98. $ vim hello.c $ gitadd hello.c $ gitreset HEAD hello.c $ gitcheckout hello.c Use the following commands: #include<stdio.h> hello.c intmain(void){ printf(“Hellon”); return 0; } intmain(void){ printf(“Hellon”); return 0; !@#$%%&*($%@#$%& } #include<stdio.h> hello.c intmain(void){ printf(“Hellon”); return 0; } 98 GitBasic
  99. 99. $ gitadd <list of files> Different ways to add files to staging area 99 GitBasic $ gitadd *.txt $ gitadd main/*.txt $ gitadd main/ $ gitadd “*.txt” $ gitadd --all Add the list of files Add all files Add all txt files in current directory Add all txt files in main directory Add all files in main directory Add all txt files in the whole project Useful commands
  100. 100. Specifies intentionally untracked files to ignore. 100 GitBasic Useful Options “.gitignore”
  101. 101. 101 GitBasic
  102. 102. gitlog If you want to review all the commits… 102 GitBasic
  103. 103. $ gitlog commit 71358d83b0249362851174566042d2f3a412f985 Author: Johnson <johnsonsu@iis.sinica.edu.tw> Date: Thu Jul 3 08:52:41 2014 +0800 modify README.txt and add hello.cfile commit 2889fd9d34ad71ea9e29046c1e529c7b0786fcb9 Author: Johnson <johnsonsu@iis.sinica.edu.tw> Date: Thu Jul 3 08:52:41 2014 +0800 Initial commit Use the following commands: 103 GitBasic master
  104. 104. gitdiff If you want to review some differences since last commit 104 GitBasic
  105. 105. If you want to modify last commit message…? 105 GitBasic
  106. 106. $ gitcommit –m “!@#$^%&*()_” $ gitlog $ gitreset --soft HEAD^ $ gitlog $ gitcommit –m “add new file xxx” $ gitlog Use the following commands: A 106 GitBasic
  107. 107. $ gitcommit –m “!@#$^%&*()_” $ gitlog $ gitcommit -amend $ gitlog Use the following commands: add new file xxx 107 GitBasic B
  108. 108. $ gitcommit –m “!@#$^%&*()_” $ gitlog $ gitcommit -amend $ gitlog Use the following commands: add new file xxx 108 GitBasic B
  109. 109. $ gitreset ––soft HEAD^ Different ways to add files to staging area 109 GitBasic $ gitreset ––hard HEAD^ $ gitreset ––hard HEAD^^ $ gitcommit ––amend –m “New Message” Undo last commit, put changes into staging Change the last commit Undo last commit and all changes Undo last 2 commits and all changes Useful commands
  110. 110. How to share your Gitrepository 110 GitBasic
  111. 111. 111 Remote Repository Master $ gitpush origin master GitBasic Hosted •GitHub •OpenFoundry •SourceForge •Google Code •BitBucket Self Managed •Gitosis •Gitorious •Gitolite •gitlab
  112. 112. 112 Remote Repository Master $ gitpull GitBasic $ gitpush origin master
  113. 113. 113 GitBasic
  114. 114. 114 GitBasic
  115. 115. 115 GitBasic
  116. 116. GitBasic $ gitremote add origin https://github.com/OpenFoundry/MOST_TRY_GIT.git Adding a Remote 116
  117. 117. GitBasic $ gitpush –u origin master Pushing to Remote 117
  118. 118. 118 GitBasic
  119. 119. 119 GitBasic
  120. 120. 120 GitBasic $ gitpull To pull changes down from the remote
  121. 121. 121 GitBasic origin master production test Having multiple remotes
  122. 122. 122 GitBasic $ gitremote add <name> <address> Working with remotes $ gitpush –u <name> <branch> $ gitremote rm<name> To add new remotes To remove remotes To push to remotes Useful commands
  123. 123. 123 GitBasic
  124. 124. $ gitreset ––soft HEAD^ Don’t do these after you push 124 GitBasic $ gitreset ––hard HEAD^ $ gitreset ––hard HEAD^^ $ gitcommit ––amend –m “New Message” Undo last commit, put changes into staging Change the last commit Undo last commit and all changes Undo last 2 commits and all changes
  125. 125. $ gitreset ––soft HEAD^ Don’t do these after you push 125 GitBasic $ gitreset ––hard HEAD^ $ gitreset ––hard HEAD^^ $ gitcommit ––amend –m “New Message” Undo last commit, put changes into staging Change the last commit Undo last commit and all changes Undo last 2 commits and all changes
  126. 126. Topic GitWorkflow 126
  127. 127. GitWorkflow 127 Remote Repository Johnson Vince Joseph
  128. 128. GitWorkflow 128
  129. 129. GitWorkflow 129 $ gitclone https://github.com/OpenFoundry/MOST_TRY_GIT.git Cloning the Repository
  130. 130. GitWorkflow 130 master Branching out dog
  131. 131. GitWorkflow 131 master Switch to dog branch and working on it dog
  132. 132. GitWorkflow 132 master List of dog branch dog
  133. 133. GitWorkflow 133 master Back to master branch dog
  134. 134. GitWorkflow 134 master Merge from dog dog HEAD
  135. 135. GitWorkflow 135 Using Command: gitlog master dog HEAD
  136. 136. GitWorkflow 136 Branch Clean up master dog HEAD
  137. 137. GitWorkflow 137 Back to dog branch master dog HEAD
  138. 138. Topic GitWorkflow 138
  139. 139. Topic 139 gittag Like most VCSs, Githas the ability to tag specific points in history as being important.
  140. 140. 140 GitBasic $ gittag v0.0.1 v0.0.2 Tagging $ gittag –a v0.0.3 –m “version 0.0.3” $ gitcheckout v0.0.1 List all tags Check out code at commit To add a new tag Useful commands $ gitpush --tags To push new tags
  141. 141. Topic GitWorkflow 141
  142. 142. Topic 142
  143. 143. Topic 143
  144. 144. Topic 144
  145. 145. Topic 145
  146. 146. Topic GitHub Flow 146
  147. 147. Topic GitHub Flow 147
  148. 148. Topic GitHub Flow 148
  149. 149. Topic GitHub Flow 149
  150. 150. Topic GitHub Flow 150
  151. 151. 151 More… •這份投影片大部分的內容都出至於SCOTT CHACON釋出的 文件與Code School Real Git的簡報,若想了解更多Git相關 技術,以下推薦您參考使用。 •英文推薦 •Pro Git •GitReference •Try Git-Code School •“Becomea gitguru.”Powered By Atlassian •GitHub Help •中文推薦 •ihower{blogging} •小惡魔–電腦技術–工作筆記 •GitMagic
  152. 152. Git版本控制教學 科技部專案操作與資源表列 Topics 152
  153. 153. 科技部專案 要做的事 科技部專案操作與資源表列 153
  154. 154. Code Hosting Sites 154
  155. 155. 主要分為兩種 1.國科會專案(doc or pdf) 成果報告書 需求分析 測試文件 2.規畫釋出(unlimited) 原始程式碼 安裝文件 使用手冊 上傳檔案類別 155
  156. 156. 科技部專案 156
  157. 157. 上傳文件 157 請依規定時程上傳文件
  158. 158. 上傳文件 158 請注意上傳文件的檔案格式
  159. 159. 主要分為兩種 1.國科會專案(doc or pdf) 成果報告書 需求分析 測試文件 2.規畫釋出(unlimited) 原始程式碼 安裝文件 使用手冊 上傳檔案類別 159
  160. 160. 放上檔案供人下載 安裝程式檔、安裝使用手冊 README、LICENSE、INSTALLATION 安裝使用手冊 160
  161. 161. FTP一般檔案上傳 161
  162. 162. FTP一般檔案上傳 162
  163. 163. FTP一般檔案上傳 163
  164. 164. FTP一般檔案上傳 164
  165. 165. FTP一般檔案上傳 165
  166. 166. FTP一般檔案上傳 166
  167. 167. FTP一般檔案上傳 167
  168. 168. FTP一般檔案上傳 168
  169. 169. FTP一般檔案上傳 169
  170. 170. FTP一般檔案上傳 170
  171. 171. FTP一般檔案上傳 171
  172. 172. FTP一般檔案上傳 172
  173. 173. FTP一般檔案上傳 173
  174. 174. 174 完成釋出
  175. 175. 175 完成釋出
  176. 176. FTP大檔案上傳 大型檔案請採用FTP上傳! 參考說明 176
  177. 177. 以上、 完成一個規畫釋出的上傳流程 177
  178. 178. 線上協助 參考此處 178
  179. 179. Johnson J. Su Linkedin:https://www.linkedin.com/in/jansu E-mail:johnsonsu@iis.sinica.edu.tw TEL:(02) 2788-3799 ext. 1478 179
  180. 180. Q & A 180

×