-
Notifications
You must be signed in to change notification settings - Fork 0
/
workshop-2.html
675 lines (598 loc) · 18 KB
/
workshop-2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
<!DOCTYPE html>
<html lang="en">
<head>
<title>KUAS-ITC git workshop - 2</title>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="shower/themes/ribbon/styles/screen-16x10.css">
<style>
img.cover {
width:1024px;
height:640px;
}
img.normal {
width: 600px;
height: 400px;
display: block;
margin: 0 auto;
box-shadow:4px 4px 3px rgba(20%,20%,40%,0.5);
}
img.center {
height: 500px;
display: block;
margin: 0 auto;
box-shadow:4px 4px 3px rgba(20%,20%,40%,0.5);
}
h4 {
font-size: 35px;
line-height: 60px;
}
section.practice {
background-image: url("pictures/shell.jpg");
}
section.practice h2 {
margin:170px 0 0;
color:#FFF;
text-align:center;
font-size:70px;
text-shadow: 0px 0px 20px #000;
}
section.practice h4 {
margin:0px 0 0;
color:#FFF;
text-align:center;
font-size:40px;
text-shadow: 0px 0px 5px #000;
}
section.practice h6 {
margin:0px 0 0;
color:#FFF;
text-align:center;
font-size:20px;
text-shadow: 0px 0px 5px #000;
}
section.practice a {
color:#FFF;
text-decoration: none;
background: none;
}
section.practice a:hover {
color:#fdd835;
}
section.hint {
background-image: url("pictures/hint.jpeg");
}
section.hint h2 {
margin:170px 0 0;
color:#FFF;
text-align:center;
font-size:70px;
text-shadow: 0px 0px 20px #000;
}
section.hint h4 {
margin:0px 0 0;
color:#FFF;
text-align:center;
font-size:40px;
line-height: 50px;
text-shadow: 0px 0px 5px #000;
}
section.hint a {
color:#FFF;
text-decoration: none;
background: none;
}
section.hint a:hover {
color:#fdd835;
}
section.command {
background-image: url("pictures/writing.jpg");
}
section.command h2 {
margin:170px 0 0;
color:#FFF;
text-align:center;
font-family: Consolas;
font-size:60px;
text-shadow: 0px 0px 20px #000;
}
section.command h4 {
margin:0px 0 0;
color:#FFF;
text-align:center;
font-size:40px;
line-height: 70px;
text-shadow: 0px 0px 10px #000;
}
section.command h6 {
margin:0px 0 0;
color:#FFF;
text-align:center;
font-size:20px;
text-shadow: 0px 0px 5px #000;
}
section.talk {
background-image: url('pictures/talk.jpg');
}
section.talk h2 {
margin:170px 0 0;
color:#FFF;
text-align:center;
font-size:60px;
text-shadow: 0px 0px 20px #000;
}
section.talk h4 {
margin:0px 0 0;
color:#FFF;
text-align:center;
font-size:40px;
line-height: 70px;
text-shadow: 0px 0px 10px #000;
}
section.magic {
background-image: url('pictures/notupload-magic.jpg');
background-size: 100% 100%;
}
section.magic h2 {
margin:170px 0 0;
color:#FFF;
text-align:center;
font-size:60px;
text-shadow: 0px 0px 20px #000;
}
section.magic h4 {
margin:0px 0 0;
color:#FFF;
text-align:center;
font-size:40px;
line-height: 70px;
text-shadow: 0px 0px 10px #000;
}
section.magic a {
color:#FFF;
text-decoration: none;
background: none;
}
section.magic a:hover {
color:#fdd835;
}
section.license h6 {
font-size: 22px;
}
section.license img.license {
float: right;
height: 25%;
}
section.cat {
background-image: url('pictures/cat.jpeg');
background-size: 100% 100%;
}
section.cat h2 {
margin:170px 0 0;
color:#FFF;
text-align:center;
font-size:60px;
text-shadow: 0px 0px 20px #000;
}
section.cat h4 {
margin:0px 0 0;
color:#FFF;
text-align:center;
font-size:40px;
line-height: 70px;
text-shadow: 0px 0px 10px #000;
}
</style>
</head>
<body class="shower list">
<header class="caption">
<h1 style="color: #FFF">KUAS-ITC git workshop -2</h1>
</header>
<section class="slide" id="cover">
<h2>git workshop - 2</h2>
<br><br><br><br><br><br><br>
<p>陳威祐</p>
<p>2016 / 10 / 24</a></p>
<img src="pictures/coffee-apple-iphone-laptop.jpg" alt="" class="cover">
<!--
To apply styles to the certain slides
set slide ID to get needed elements
-->
<style>
#cover h2 {
margin:30px 0 0;
color:#FFF;
text-align:center;
font-size:70px;
}
#cover p {
line-height: 10px;
text-align:center;
color:#FFF;
font-style:italic;
font-size:30px;
}
</style>
</section>
<section class="slide">
<h2>About me</h2>
<ul>
<li>Python, C#, Linux, git</li>
<li><a href="https://github.com/aweimeow">Github</a></li>
<li><a href="https://blog.aweimeow.tw">blog</a></li>
<li>
Slide: <a href="https://github.com/aweimeow/git-workshop-slide">https://github.com/aweimeow/git-workshop-slide</a>
<ul>
<p class="note">如果大大們喜歡的話請點個 Star <(_ _)></p>
</ul>
</li>
</ul>
</section>
<section class="slide talk">
<h2>GIT 原理運作</h2>
</section>
<section class="slide">
<h2>git init</h2>
<h4>
當我們執行 <code>git init</code> ...
<ul>
<ul>
<li>會有一個 <code>.git</code> 資料夾</li>
<li>資料夾中有:<font style="font-size: 28px"><code>HEAD</code>、<code>index</code>、<code>objects</code>、<code>refs</code></font></li>
<ul style="font-size: 28px; line-height: 48px;">
<li>HEAD: 指向目前分支</li>
<li>index: 暫存區資訊</li>
<li>objects: 所有資料都在這</li>
<li>ref: 提交物件的指標</li>
</ul>
</ul>
</ul>
</h4>
</section>
<section class="slide hint">
<h2>Live Demo Time</h2>
<h4>demo-1.json</h4>
</section>
<section class="slide">
<h2>objects</h2>
<pre style="background-color: #EEE"><code>$ echo 'test content' | git hash-object -w --stdin
d670460b4b4aece5915caf5c68d12f560a9fe3e4
$ tree .git/objects
.git/objects
├── d6
│ └── 70460b4b4aece5915caf5c68d12f560a9fe3e4
├── info
└── pack</code></pre>
</section>
<section class="slide">
<h2>tree and blob</h2>
<h4>Git 以一種類似 UNIX 檔案系統的方式來儲存內容</h4>
<br/>
<h4>
<ul>
<li><code>tree</code>:對應檔案系統中的目錄</li>
<li><code>blob</code>:對應檔案系統中的檔案</li>
</ul>
</h4>
</section>
<section class="slide hint">
<h2>Live Demo Time</h2>
<h4>demo-2.json</h4>
</section>
<section class="slide">
<img src="pictures/git-structure.png" class="normal"/>
</section>
<section class="slide hint">
<h2>原理介紹就到這裡</h2>
<h4><a href="https://git-scm.com/book/zh-tw/v1/Git-內部原理-Git-物件">有興趣點我了解更多</a></h4>
</section>
<section class="slide" id="new-travel-for-magic">
<img src="pictures/door-opening.jpg" alt="" class="cover">
<style>
#new-travel-for-magic h2 {
margin:170px 0 0;
color:#FFF;
text-align:center;
font-size:70px;
text-shadow: 2px 2px 10px #000;
}
#new-travel-for-magic h4 {
margin:20px 0 0;
color:#3f51b5;
text-align:center;
font-size:50px;
font-weight: bold;
text-shadow: 0px 0px 5px #FFFFFF, 2px 2px 10px #2196f3;
}
</style>
<h2>接下來開始新的旅程!</h2>
<h4>成為魔法師吧孩子!</h4>
</section>
<section class="slide magic">
<h2>How to write README.md</h2>
<h4><a href="http://markdown.tw/">Markdown</a>、<a href="http://hackmd.io/">HackMD</a>、<a href="http://dillinger.io/">Dillinger</a></h4>
</section>
<section class="slide">
<h2>Markdown Syntax: 最常用到的幾種</h2>
<pre style="background-color: #EEE; font-size: 20px">
<code># h1
## h2
#### h4
- List 1 ( 也可以用 * 開頭)
- List 2
[文字](連結網址)
![圖片說明](http://i.imgur.com/8YW5Fqhm.jpg)
```python
print "HelloWorld"
```</code></pre>
</section>
<section class="slide">
<img src="pictures/markdown-demo.jpg" alt="" class="cover">
</section>
<section class="slide practice">
<h2>Practice - 1</h2>
<h4>Write README.md for repo and publish to Github</h4>
</section>
<section class="slide magic">
<h2>.gitconfig</h2>
<h4><a href="https://git-scm.com/book/zh-tw/v1/開始-初次設定Git">gitconfig - 初次設定Git</a></h4>
</section>
<section class="slide">
<img src="pictures/gitconfig.jpg" class="center"/>
</section>
<section class="slide">
<h2>我剛剛看了什麼 (゚д゚≡゚д゚)</h2>
<h4>
<ul>
<li>user: 告訴 git 你是誰 (Name, email)</li>
<li>core: 關於 git 的一些相關預設配置
<ul style="font-size: 24px">
<li><code>whitespace = cr-at-eol</code> Windows and Unix's newline format</li>
<li><code>quotepath: off</code> 禁止 git 把中文檔名轉義 (demo-3.json)</li>
</ul>
</li>
<li>alias: 把常用的指令寫成縮寫</li>
</ul>
</h4>
</section>
<section class="slide">
<h2>git lg</h2>
<pre style="background-color: #EEE; font-size: 20px">
<code>git config --global alias.lg \
"log --color --graph --all --pretty=format:\
'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)\
%C(bold blue)<%an>%Creset' --abbrev-commit --"</code></pre>
<img src="pictures/git-lg.jpg" style="width: 100%"/>
</section>
<section class="slide practice">
<h2>Practice - 2</h2>
<h4>把 git 的慣用編輯器改成你喜歡的 editor!</h4>
</section>
<section class="slide magic">
<h2>LICENSE</h2>
<h4><a href="http://choosealicense.com/">選擇適合 project 的那個授權</a></h4>
</section>
<section class="slide">
<img src="pictures/chooselicense.jpg" class="cover"/>
</section>
<section class="slide license">
<h2>MIT License</h2>
<h4><code>我希望授權簡單就好,不須太嚴格</code></h4>
<h6>
MIT 授權是一個寬鬆並簡短明瞭的授權,它<font style="color: red">提供給他人對於你的程式碼一切權利(包含使用、重製、修改、合併、出版、販售重製品 ... 等)</font><br>
<font style="color: red">作者僅想保留版權</font>,對於其他沒有任何限制,不過因為無償提供的緣故,所以也主張免除擔保責任。<br>
<font style="color: red">修改者需要在發行版中保留原作者的許可協議聲明。</font><br>
</h6>
<img src="pictures/mit-license.png" class="license">
</section>
<section class="slide license">
<h2>Apache License 2.0 (APL 2.0)</h2>
<h4><code>我在乎我的專利權</code></h4>
<h6>
APL 2.0 <font style="color: red">與 MIT 一樣能夠使用、重製、修改、販售重製品 ... 等權利</font>,<br>
在重製時:<br>
<ul>
<li>需附上 APL 2.0 全文</li>
<li>標示修改的檔案</li>
<li>保留原程式該保留的各項聲明</li>
<li>讓後手能夠閱讀到前手的聲明資訊</li>
</ul>
</h6>
</section>
<section class="slide license">
<h2>GNU General Public License 3.0 (GPLv3)</h2>
<h4><code>我在乎的是分享、改進</code></h4>
<h6>
<font style="color: red">GPLv3 要求任何貢獻者、衍伸開發作品同樣以 GPLv3 來散布,</font><br/>
(也就是說,只要使用到 授權為 GPLv3 的 library 就須以 GPLv3 作為授權)<br/>
GPLv3 主張程式碼開源、免費使用、引用、修改、開發衍伸產品,<br/>
但<font style="color: red">不允許修改後的程式碼、衍伸的產品做為閉源商業軟體發布及銷售</font><br/>
</h6>
<img src="pictures/GPLv3-license.png" class="license"/>
</section>
<section class="slide">
<h2>當然你也可以參考這個選擇</h2>
<img src="pictures/Github-license-route.jpeg" class="normal"/>
source: https://read01.com/dB8mxE.html
</section>
<section class="slide practice">
<h2>Practice - 3</h2>
<h4>Add a LICENSE for your repository</h4>
<h4>Useful Tool: <a href="http://www.addalicense.com/">addalicense</a></h4>
</section>
<section class="slide magic">
<h2>How to add LICENSE to Github repo</h2>
<h4><a href="https://help.github.com/articles/open-source-licensing/">Github Documentation</a></h4>
</section>
<section class="slide magic">
<h2>SSH key and push by ssh</h2>
<h4><a href="https://git-scm.com/book/zh-tw/v1/伺服器上的-Git-生成-SSH-公開金鑰">Git Book Tutorial</a></h4>
</section>
<section class="slide">
<h2>remote</h2>
<h4>add remote branch example</h4>
<h4 style="font-size: 18px; color: red;"><code>git remote add origin git@github.com:aweimeow/git-workshop-example.git</code></h4>
<h4 style="font-size: 18px;"><code>git remote add origin https://github.com/aweimeow/git-workshop-example.git</code></h4>
<br>
<h4 style="font-size: 30px;"><code>git remote -v</code></h4>
<p class="note"># 查看目前的 remote branch</p>
</section>
<section class="slide">
<h2>產生 ssh key</h2>
<pre style="background-color: #EEE; font-size: 20px">
<code>$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/schacon/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/schacon/.ssh/id_rsa.
Your public key has been saved in /Users/schacon/.ssh/id_rsa.pub.
The key fingerprint is:
43:c5:5b:5f:b1:f1:50:43:ad:20:a6:92:6a:1f:9a:3a schacon@agadorlaptop.local</code></pre>
</section>
<section class="slide cat">
<h2>我所碰到的那些問題 - 1</h2>
<h4>哎呀我不小心把我的密碼傳上去了呀</h4>
</section>
<section class="slide">
<img src="pictures/notupload-lu.jpg" class="center" style="height: 400px"/>
<br/>
<h2>這個例子由 <font style="color: purple; font-weight: bold;">高應大學生議長</font> 熱情贊助</h2>
</section>
<section class="slide">
<img src="pictures/pass-upload-to-github.jpg" class="center"/>
</section>
<section class="slide hint">
<h2>BFG Repo-Cleaner</h2>
<h4><a href="https://rtyley.github.io/bfg-repo-cleaner/">BFG Repo-Cleaner</a></h4>
</section>
<section class="slide">
<h2>BFG Repo-Cleaner</h2>
<h4>
<ul>
<li>移除太大的檔案(超過 10MBytes)</li>
<li>移除密碼(像我們這個例子)</li>
<li>移除憑證、金鑰 ... 等</li>
<li>或是其他的隱私資料(Ex. 未公開的 API 網址 .. 等)</li>
</ul>
</h4>
</section>
<section class="slide">
<h2>Let's take some examples :)</h2>
<ul>
<li>Delete all file named 'id_rsa' or 'id_dsa'</li>
<ul>
<li><code>bfg --delete-files id_{dsa,rsa} my-repo.git</code></li>
</ul>
<li>Remove all blobs bigger than 50 megabytes</li>
<ul>
<li><code>bfg --strip-blobs-bigger-than 50M my-repo.git</code></li>
</ul>
<li>Replace all passwords listed in a file (prefix lines 'regex:' or 'glob:' if required) with <code>***REMOVED***</code> </li>
<ul>
<li><code>bfg --replace-text passwords.txt my-repo.git</code></li>
</ul>
</ul>
</section>
<section class="slide cat">
<h2>我所碰到的那些問題 - 2</h2><br>
<h4>我想還原到上個 commit,<br>可是我已經推上去了耶 幫QQ</h4>
</section>
<section class="slide">
<h4>
<code>Remote branch</code>
<ul>
<li>b4f39a - Third Commit and pushed <- HEAD</li>
<li>04534f - Second Commit</li>
<li>4b964a - First Commit</li>
</ul>
<code>Local branch</code>
<ul>
<li><s>b4f39a - Third Commit and pushed</s></li>
<li>04534f - Second Commit ← <code>HEAD</code></li>
<li>4b964a - First Commit</li>
</ul>
</h4>
</section>
<section class="slide talk">
<h2>好險我一個機智還記得怎麼 revert commit</h2>
<h4><s>遠端的怎麼沒有 revert 阿阿阿</s></h4>
</section>
<section class="slide command">
<h2 style="font-size: 36px;">git push -f [remote_name] [branch_name]</h2>
<h4 style="color: #f8bbd0; font-weight: bold;">Force push and rewrite commit</h4>
</section>
<section class="slide cat">
<h2>我所碰到的那些問題 - 3</h2>
<h4>我突然想從某個 Commit 分出<br>一個 branch 還來得及嗎?</h4>
</section>
<section class="slide">
<h2>original</h2>
<h4>
<ul>
<li>4b964a - First Commit</li>
<li>04534f - Second Commit</li>
<li>b4f39a - Third Commit</li>
<li>a98787 - Fourth Commit ← <code>master, HEAD</code></li>
</ul>
</h4>
</section>
<section class="slide">
<h2>Step 1. checkout to target</h2>
<h4>
<ul>
<li>4b964a - First Commit</li>
<li>04534f - Second Commit ← <code>HEAD</code></li>
<li>b4f39a - Third Commit</li>
<li>a98787 - Fourth Commit ← <code>master</code></li>
</ul>
</h4>
</section>
<section class="slide">
<h2>Step 2. checkout new branch</h2>
<h4>
<ul>
<li>4b964a - First Commit</li>
<li>04534f - Second Commit</li>
<ul>
<li>1e27cc - new branch ← <code>dev, HEAD</code></li>
</ul>
<li>b4f39a - Third Commit</li>
<li>a98787 - Fourth Commit ← <code>master</code></li>
</ul>
</h4>
</section>
<section class="slide">
<h2>Step 3. Cont. on dev or back to master</h2>
<h4>
<ul>
<li>4b964a - First Commit</li>
<li>04534f - Second Commit</li>
<ul>
<li>1e27cc - new branch ← <code>dev</code></li>
</ul>
<li>b4f39a - Third Commit</li>
<li>a98787 - Fourth Commit ← <code>master, HEAD</code></li>
</ul>
</h4>
</section>
<section class="slide">
<h2>Reference</h2>
<ul>
<li><a href="http://denny.one/HackGen-2014-workshop/">Git Workshop - Denny Huang</a></li>
<li><a href="https://speakerdeck.com/crboy/code-smart-dont-code-hard">Code Smart, Don't Code hard - CrBoy</a></li>
<li><a href="https://git-scm.com/book/zh-tw">Git Book</a></li>
</ul>
</section>
<section class="slide talk">
<h2>Slide: https://github.com/aweimeow/git-workshop-slide</h2>
</section>
<!--
To hide progress bar from entire presentation
just remove “progress” element.
-->
<div class="progress"></div>
<script src="shower/shower.min.js"></script>
</body>
</html>