SlideShare a Scribd company logo
1 of 180
Download to read offline
自由軟體鑄造場作業暨智財權說明會 
版本控制系統與科技部專案(以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. 1478 
2
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 revisions of a file 
GitBasic 
26
No Network Needed 
Performing a diff 
Viewing file history 
Committing changes 
Merging branches 
Obtaining other revisions of a file 
Switching branches 
GitBasic 
27
(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){ 
printf(“Hellon”); 
return 0; 
} 
34
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
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
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
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
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
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
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
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
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
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
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
GitSnapshots 
GitBasic 
46
This is Johnson Su’s excellent project. 
Licensed under GPL. 
README.txt 
#include<stdio.h> 
hello.c 
intmain(void){ 
printf(“Hellon”); 
return 0; 
} 
47
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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 
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 
$ gitconfig--global color.uiture 
71 
GitBasic
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 
gitclone repository from remote server 
gitinitial a repository in local system 
73 
GitBasic
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
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 Lifecycle 
77 
GitBasic
$ 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 Lifecycle 
79 
GitBasic
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 
GitBasic
$ 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
$ 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
$ 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
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
$ 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
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
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
$ 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 filename 
Commit a version 
gitadd filename 
gitcommit 
File Status Lifecycle 
add/edit the file 
gitcheckout filename 
91 
GitBasic
$ 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
$ 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
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
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
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
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
$ 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
$ 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
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 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
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 
Use the following commands: 
A 
106 
GitBasic
$ gitcommit –m “!@#$^%&*()_” 
$ gitlog 
$ gitcommit -amend 
$ gitlog 
Use the following commands: 
add new file xxx 
107 
GitBasic 
B
$ gitcommit –m “!@#$^%&*()_” 
$ gitlog 
$ gitcommit -amend 
$ gitlog 
Use the following commands: 
add new file xxx 
108 
GitBasic 
B
$ 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
How to share your Gitrepository 
110 
GitBasic
111 
Remote Repository 
Master 
$ gitpush origin master 
GitBasic 
Hosted 
•GitHub 
•OpenFoundry 
•SourceForge 
•Google Code 
•BitBucket 
Self Managed 
•Gitosis 
•Gitorious 
•Gitolite 
•gitlab
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> 
To add new remotes 
To remove remotes 
To push to remotes 
Useful commands
123 
GitBasic
$ 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
$ 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
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 tags 
Check out code at commit 
To add a new tag 
Useful commands 
$ gitpush --tags 
To push new tags
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 
•GitReference 
•Try Git-Code School 
•“Becomea gitguru.”Powered By Atlassian 
•GitHub Help 
•中文推薦 
•ihower{blogging} 
•小惡魔–電腦技術–工作筆記 
•GitMagic
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. 1478 
179
Q & A 
180

More Related Content

Viewers also liked

A Guideline to Test Your Own Code - Developer Testing
A Guideline to Test Your Own Code - Developer TestingA Guideline to Test Your Own Code - Developer Testing
A Guideline to Test Your Own Code - Developer TestingFolio3 Software
 
Code tuning techniques
Code tuning techniquesCode tuning techniques
Code tuning techniquesAsha Sari
 
程序员发展漫谈
程序员发展漫谈程序员发展漫谈
程序员发展漫谈Horky Chen
 
高品質軟體的基本動作 101 + 102 for NUU
高品質軟體的基本動作 101 + 102 for NUU高品質軟體的基本動作 101 + 102 for NUU
高品質軟體的基本動作 101 + 102 for NUUSu Jan
 
Design in construction
Design in constructionDesign in construction
Design in constructionAsha Sari
 
Design in construction
Design in constructionDesign in construction
Design in constructionAsha Sari
 
程序员实践之路
程序员实践之路程序员实践之路
程序员实践之路Horky Chen
 
Defencive programming
Defencive programmingDefencive programming
Defencive programmingAsha Sari
 
Java scriptcore brief introduction
Java scriptcore brief introductionJava scriptcore brief introduction
Java scriptcore brief introductionHorky Chen
 
代码大全(内训)
代码大全(内训)代码大全(内训)
代码大全(内训)Horky Chen
 
Code tuning strategies
Code tuning strategiesCode tuning strategies
Code tuning strategiesAsha Sari
 
高品質軟體的基本動作 101 for NTHU
高品質軟體的基本動作 101 for NTHU高品質軟體的基本動作 101 for NTHU
高品質軟體的基本動作 101 for NTHUSu Jan
 
Code Tuning
Code TuningCode Tuning
Code Tuningbgtraghu
 
The pseudocode
The pseudocodeThe pseudocode
The pseudocodeAsha Sari
 
Rm 1 Intro Types Research Process
Rm   1   Intro Types   Research ProcessRm   1   Intro Types   Research Process
Rm 1 Intro Types Research Processitsvineeth209
 

Viewers also liked (19)

A Guideline to Test Your Own Code - Developer Testing
A Guideline to Test Your Own Code - Developer TestingA Guideline to Test Your Own Code - Developer Testing
A Guideline to Test Your Own Code - Developer Testing
 
Integration
IntegrationIntegration
Integration
 
Code tuning techniques
Code tuning techniquesCode tuning techniques
Code tuning techniques
 
程序员发展漫谈
程序员发展漫谈程序员发展漫谈
程序员发展漫谈
 
Coding Style
Coding StyleCoding Style
Coding Style
 
高品質軟體的基本動作 101 + 102 for NUU
高品質軟體的基本動作 101 + 102 for NUU高品質軟體的基本動作 101 + 102 for NUU
高品質軟體的基本動作 101 + 102 for NUU
 
Variables
VariablesVariables
Variables
 
Design in construction
Design in constructionDesign in construction
Design in construction
 
Design in construction
Design in constructionDesign in construction
Design in construction
 
程序员实践之路
程序员实践之路程序员实践之路
程序员实践之路
 
Defencive programming
Defencive programmingDefencive programming
Defencive programming
 
Java scriptcore brief introduction
Java scriptcore brief introductionJava scriptcore brief introduction
Java scriptcore brief introduction
 
代码大全(内训)
代码大全(内训)代码大全(内训)
代码大全(内训)
 
Code tuning strategies
Code tuning strategiesCode tuning strategies
Code tuning strategies
 
高品質軟體的基本動作 101 for NTHU
高品質軟體的基本動作 101 for NTHU高品質軟體的基本動作 101 for NTHU
高品質軟體的基本動作 101 for NTHU
 
Code Complete
Code CompleteCode Complete
Code Complete
 
Code Tuning
Code TuningCode Tuning
Code Tuning
 
The pseudocode
The pseudocodeThe pseudocode
The pseudocode
 
Rm 1 Intro Types Research Process
Rm   1   Intro Types   Research ProcessRm   1   Intro Types   Research Process
Rm 1 Intro Types Research Process
 

Similar to MOST_OpenFoundry_version control system_Git

Ankara jug mayıs 2013 sunumu
Ankara jug mayıs 2013 sunumuAnkara jug mayıs 2013 sunumu
Ankara jug mayıs 2013 sunumuAnkara JUG
 
Tài liệu sử dụng GitHub
Tài liệu sử dụng GitHubTài liệu sử dụng GitHub
Tài liệu sử dụng GitHubviet nghiem
 
That's (g)it! par Sébastien Dawans CETIC
That's (g)it! par Sébastien Dawans CETICThat's (g)it! par Sébastien Dawans CETIC
That's (g)it! par Sébastien Dawans CETICLa FeWeb
 
Raspberry Pi Using Python
Raspberry Pi Using PythonRaspberry Pi Using Python
Raspberry Pi Using PythonSeggy Segaran
 
Git Going for the Transylvania JUG
Git Going for the Transylvania JUGGit Going for the Transylvania JUG
Git Going for the Transylvania JUGMatthew McCullough
 
JavaZone 2022 - Building Kotlin DSL.pdf
JavaZone 2022 - Building Kotlin DSL.pdfJavaZone 2022 - Building Kotlin DSL.pdf
JavaZone 2022 - Building Kotlin DSL.pdfAnton Arhipov
 
Let's contribute, HTML5Rocks/ko!
Let's contribute, HTML5Rocks/ko!Let's contribute, HTML5Rocks/ko!
Let's contribute, HTML5Rocks/ko!Chang W. Doh
 
Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control SystemVictor Wong
 
Intro to Git Devnet-1080 Cisco Live 2018
Intro to Git Devnet-1080 Cisco Live 2018Intro to Git Devnet-1080 Cisco Live 2018
Intro to Git Devnet-1080 Cisco Live 2018Ashley Roach
 
Devoxx Ukraine 2018 - Kotlin DSL in under an hour
Devoxx Ukraine 2018 - Kotlin DSL in under an hourDevoxx Ukraine 2018 - Kotlin DSL in under an hour
Devoxx Ukraine 2018 - Kotlin DSL in under an hourAnton Arhipov
 
Biicode OpenExpoDay
Biicode OpenExpoDayBiicode OpenExpoDay
Biicode OpenExpoDayfcofdezc
 
Group3-Gravitation.pdf
Group3-Gravitation.pdfGroup3-Gravitation.pdf
Group3-Gravitation.pdfVidhanSingh11
 
The Ring programming language version 1.9 book - Part 21 of 210
The Ring programming language version 1.9 book - Part 21 of 210The Ring programming language version 1.9 book - Part 21 of 210
The Ring programming language version 1.9 book - Part 21 of 210Mahmoud Samir Fayed
 
Python分享
Python分享Python分享
Python分享fangdeng
 

Similar to MOST_OpenFoundry_version control system_Git (20)

Ankara jug mayıs 2013 sunumu
Ankara jug mayıs 2013 sunumuAnkara jug mayıs 2013 sunumu
Ankara jug mayıs 2013 sunumu
 
Becoming a Git Master
Becoming a Git MasterBecoming a Git Master
Becoming a Git Master
 
Tài liệu sử dụng GitHub
Tài liệu sử dụng GitHubTài liệu sử dụng GitHub
Tài liệu sử dụng GitHub
 
Intro to Git and GitHub
Intro to Git and GitHubIntro to Git and GitHub
Intro to Git and GitHub
 
That's (g)it! par Sébastien Dawans CETIC
That's (g)it! par Sébastien Dawans CETICThat's (g)it! par Sébastien Dawans CETIC
That's (g)it! par Sébastien Dawans CETIC
 
Raspberry Pi Using Python
Raspberry Pi Using PythonRaspberry Pi Using Python
Raspberry Pi Using Python
 
Git Going for the Transylvania JUG
Git Going for the Transylvania JUGGit Going for the Transylvania JUG
Git Going for the Transylvania JUG
 
JavaZone 2022 - Building Kotlin DSL.pdf
JavaZone 2022 - Building Kotlin DSL.pdfJavaZone 2022 - Building Kotlin DSL.pdf
JavaZone 2022 - Building Kotlin DSL.pdf
 
Let's contribute, HTML5Rocks/ko!
Let's contribute, HTML5Rocks/ko!Let's contribute, HTML5Rocks/ko!
Let's contribute, HTML5Rocks/ko!
 
Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control System
 
Intro to Git Devnet-1080 Cisco Live 2018
Intro to Git Devnet-1080 Cisco Live 2018Intro to Git Devnet-1080 Cisco Live 2018
Intro to Git Devnet-1080 Cisco Live 2018
 
Devoxx Ukraine 2018 - Kotlin DSL in under an hour
Devoxx Ukraine 2018 - Kotlin DSL in under an hourDevoxx Ukraine 2018 - Kotlin DSL in under an hour
Devoxx Ukraine 2018 - Kotlin DSL in under an hour
 
Introduction to git
Introduction to gitIntroduction to git
Introduction to git
 
Biicode OpenExpoDay
Biicode OpenExpoDayBiicode OpenExpoDay
Biicode OpenExpoDay
 
Working with Git
Working with GitWorking with Git
Working with Git
 
Java fx tools
Java fx toolsJava fx tools
Java fx tools
 
Group3-Gravitation.pdf
Group3-Gravitation.pdfGroup3-Gravitation.pdf
Group3-Gravitation.pdf
 
The Ring programming language version 1.9 book - Part 21 of 210
The Ring programming language version 1.9 book - Part 21 of 210The Ring programming language version 1.9 book - Part 21 of 210
The Ring programming language version 1.9 book - Part 21 of 210
 
Python分享
Python分享Python分享
Python分享
 
1 c introduction
1 c introduction1 c introduction
1 c introduction
 

Recently uploaded

Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 
computer application and construction management
computer application and construction managementcomputer application and construction management
computer application and construction managementMariconPadriquez1
 
Comparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization TechniquesComparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization Techniquesugginaramesh
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catcherssdickerson1
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 

Recently uploaded (20)

Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 
computer application and construction management
computer application and construction managementcomputer application and construction management
computer application and construction management
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
Comparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization TechniquesComparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization Techniques
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 

MOST_OpenFoundry_version control system_Git

  • 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
  • 10. What is Git? GitBasic 9
  • 11. Git is an open source, distributed version control system designed for speed and efficiency GitBasic 10
  • 12. Gitis an open source, distributed version control system designed for speed and efficiency GitBasic 11
  • 13. Gitis an open source, distributedversion control system designed for speed and efficiency GitBasic 12
  • 18. (almost) everything is local GitBasic 17
  • 20. which means everything is fast GitBasic 19
  • 21. which means everything is fast every clone is a backup GitBasic 20
  • 22. which means everything is fast every clone is a backup work offline GitBasic 21
  • 23. No Network Needed GitBasic 22
  • 24. No Network Needed Performing a diff GitBasic 23
  • 25. No Network Needed Performing a diff Viewing file history GitBasic 24
  • 26. No Network Needed Performing a diff Viewing file history Committing changes GitBasic 25
  • 27. No Network Needed Performing a diff Viewing file history Committing changes Merging branches Obtaining other revisions of a file GitBasic 26
  • 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. (almost) never removes data GitBasic 29
  • 30. Compare with svn… GitBasic 30
  • 31. Snapshots, not Patches GitBasic 31
  • 32. File Based Delta Storage GitBasic 32
  • 33. First… Let’s make an example of svn GitBasic 33
  • 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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
  • 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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
  • 68. 68 GitBasic Gitcommands (Live demo)
  • 69. Beforewe start to use Gitrepository…… 69 GitBasic
  • 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. Let’s start using Git first… Create or Clone a Gitrepository 72 GitBasic
  • 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 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. Untracked Unmodified Modified Staged initial gitinit File Status Lifecycle 75 GitBasic
  • 76. $ mkdirproject $ cd project $ touch README.txt $ gitinit $ tree -a Use the following commands: 76 GitBasic
  • 77. Untracked Unmodified Modified Staged initial gitinit add the file 1.gitadd filename 2.gitcommit File Status Lifecycle 77 GitBasic
  • 78. $ gitadd . $ gitstatus $ gitcommit –m “Initial commit” Use the following commands: 78 GitBasic
  • 79. Untracked Unmodified Modified Staged initial gitinit add the file add/edit the file gitadd filename File Status Lifecycle 79 GitBasic
  • 80. README.txt Use the following commands: 80 GitBasic
  • 81. $ vim README.txt Use the following commands: This is Johnson Su’s excellentproject. Licensed under GPL. README.txt 81 GitBasic
  • 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. $ 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. $ 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. 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. $ 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. 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. 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. $ gitstatus $ gitrmhello.c $ gitstatus Use the following commands: 89 GitBasic
  • 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. $ 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. $ 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. 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. 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. 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. 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. $ 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. $ 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. Specifies intentionally untracked files to ignore. 100 GitBasic Useful Options “.gitignore”
  • 102. gitlog If you want to review all the commits… 102 GitBasic
  • 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. gitdiff If you want to review some differences since last commit 104 GitBasic
  • 105. If you want to modify last commit message…? 105 GitBasic
  • 106. $ gitcommit –m “!@#$^%&*()_” $ gitlog $ gitreset --soft HEAD^ $ gitlog $ gitcommit –m “add new file xxx” $ gitlog Use the following commands: A 106 GitBasic
  • 107. $ gitcommit –m “!@#$^%&*()_” $ gitlog $ gitcommit -amend $ gitlog Use the following commands: add new file xxx 107 GitBasic B
  • 108. $ gitcommit –m “!@#$^%&*()_” $ gitlog $ gitcommit -amend $ gitlog Use the following commands: add new file xxx 108 GitBasic B
  • 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. How to share your Gitrepository 110 GitBasic
  • 111. 111 Remote Repository Master $ gitpush origin master GitBasic Hosted •GitHub •OpenFoundry •SourceForge •Google Code •BitBucket Self Managed •Gitosis •Gitorious •Gitolite •gitlab
  • 112. 112 Remote Repository Master $ gitpull GitBasic $ gitpush origin master
  • 116. GitBasic $ gitremote add origin https://github.com/OpenFoundry/MOST_TRY_GIT.git Adding a Remote 116
  • 117. GitBasic $ gitpush –u origin master Pushing to Remote 117
  • 120. 120 GitBasic $ gitpull To pull changes down from the remote
  • 121. 121 GitBasic origin master production test Having multiple remotes
  • 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
  • 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. $ 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
  • 127. GitWorkflow 127 Remote Repository Johnson Vince Joseph
  • 129. GitWorkflow 129 $ gitclone https://github.com/OpenFoundry/MOST_TRY_GIT.git Cloning the Repository
  • 130. GitWorkflow 130 master Branching out dog
  • 131. GitWorkflow 131 master Switch to dog branch and working on it dog
  • 132. GitWorkflow 132 master List of dog branch dog
  • 133. GitWorkflow 133 master Back to master branch dog
  • 134. GitWorkflow 134 master Merge from dog dog HEAD
  • 135. GitWorkflow 135 Using Command: gitlog master dog HEAD
  • 136. GitWorkflow 136 Branch Clean up master dog HEAD
  • 137. GitWorkflow 137 Back to dog branch master dog HEAD
  • 139. Topic 139 gittag Like most VCSs, Githas the ability to tag specific points in history as being important.
  • 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
  • 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
  • 155. 主要分為兩種 1.國科會專案(doc or pdf) 成果報告書 需求分析 測試文件 2.規畫釋出(unlimited) 原始程式碼 安裝文件 使用手冊 上傳檔案類別 155
  • 159. 主要分為兩種 1.國科會專案(doc or pdf) 成果報告書 需求分析 測試文件 2.規畫釋出(unlimited) 原始程式碼 安裝文件 使用手冊 上傳檔案類別 159
  • 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. Q & A 180