-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathslides.html
1050 lines (1044 loc) · 86.4 KB
/
slides.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
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="generator" content="pandoc">
<meta name="author" content="wkevin">
<title>slides</title>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
<link rel="stylesheet" href="reveal.js/dist/reset.css">
<link rel="stylesheet" href="reveal.js/dist/reveal.css">
<style>
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<style>
a.sourceLine { display: inline-block; line-height: 1.25; }
a.sourceLine { pointer-events: none; color: inherit; text-decoration: inherit; }
a.sourceLine:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode { white-space: pre; position: relative; }
div.sourceCode { margin: 1em 0; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
code.sourceCode { white-space: pre-wrap; }
a.sourceLine { text-indent: -1em; padding-left: 1em; }
}
pre.numberSource a.sourceLine
{ position: relative; left: -4em; }
pre.numberSource a.sourceLine::before
{ content: attr(title);
position: relative; left: -1em; text-align: right; vertical-align: baseline;
border: none; pointer-events: all; display: inline-block;
-webkit-touch-callout: none; -webkit-user-select: none;
-khtml-user-select: none; -moz-user-select: none;
-ms-user-select: none; user-select: none;
padding: 0 4px; width: 4em;
}
pre.numberSource { margin-left: 3em; padding-left: 4px; }
div.sourceCode
{ color: #cccccc; background-color: #303030; }
@media screen {
a.sourceLine::before { text-decoration: underline; }
}
code span.al { color: #ffcfaf; } /* Alert */
code span.an { color: #7f9f7f; font-weight: bold; } /* Annotation */
code span.at { } /* Attribute */
code span.bn { color: #dca3a3; } /* BaseN */
code span.bu { } /* BuiltIn */
code span.cf { color: #f0dfaf; } /* ControlFlow */
code span.ch { color: #dca3a3; } /* Char */
code span.cn { color: #dca3a3; font-weight: bold; } /* Constant */
code span.co { color: #7f9f7f; } /* Comment */
code span.cv { color: #7f9f7f; font-weight: bold; } /* CommentVar */
code span.do { color: #7f9f7f; } /* Documentation */
code span.dt { color: #dfdfbf; } /* DataType */
code span.dv { color: #dcdccc; } /* DecVal */
code span.er { color: #c3bf9f; } /* Error */
code span.ex { } /* Extension */
code span.fl { color: #c0bed1; } /* Float */
code span.fu { color: #efef8f; } /* Function */
code span.im { } /* Import */
code span.in { color: #7f9f7f; font-weight: bold; } /* Information */
code span.kw { color: #f0dfaf; } /* Keyword */
code span.op { color: #f0efd0; } /* Operator */
code span.ot { color: #efef8f; } /* Other */
code span.pp { color: #ffcfaf; font-weight: bold; } /* Preprocessor */
code span.sc { color: #dca3a3; } /* SpecialChar */
code span.ss { color: #cc9393; } /* SpecialString */
code span.st { color: #cc9393; } /* String */
code span.va { } /* Variable */
code span.vs { color: #cc9393; } /* VerbatimString */
code span.wa { color: #7f9f7f; font-weight: bold; } /* Warning */
</style>
<link rel="stylesheet" href="reveal.js/dist/theme/league.css" id="theme">
<link rel="stylesheet" href="reveal.js/plugin/highlight/monokai.css">
<link rel="stylesheet" href="assets/css/slides.css"/>
<!-- Printing and PDF exports -->
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? 'reveal.js/css/print/pdf.scss' : 'reveal.js/css/print/paper.scss';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
</head>
<body>
<div class="reveal">
<div class="slides">
<section id="title-slide">
<h1 class="title"><img data-src="img/logo.png" /></h1>
<p class="author">wkevin</p>
</section>
<section id="history" class="title-slide slide level2"><h2>History</h2><table>
<tbody>
<tr class="odd">
<td>2016.7</td>
<td>v1.0</td>
<td>完成 Git 基础</td>
</tr>
<tr class="even">
<td>2017.4</td>
<td>v1.1</td>
<td>局部修订</td>
</tr>
<tr class="odd">
<td>2019.8</td>
<td>v1.2</td>
<td>修订近几年的变化,删除svn对比的内容</td>
</tr>
</tbody>
</table></section>
<section id="git-基础" class="title-slide slide level1" data-background-color="#3962c3"><h1>Git 基础</h1></section>
<section><section id="源起" class="title-slide slide level1"><h1>源起</h1></section><section id="vcs-version-control-system" class="title-slide slide level2"><h2>VCS (Version Control System)</h2><ul>
<li><strong>SCCS</strong>(Source Code Control System) – 1970+, M.J.Rochkind</li>
<li><strong>RCS</strong>(Revision Control System) – 1980+, Walter F. Tichy</li>
<li><strong>CVS</strong>(Concurrent Version System) – 1986, Dick Grune</li>
<li><strong>SVN</strong>(Subversion) – 2001</li>
<li><strong>BitKeeper</strong></li>
<li><strong>Mercurial</strong></li>
<li><strong>Git</strong> – 2005.4, Linus Torvalds</li>
</ul></section><section id="git从何而来" class="title-slide slide level2"><h2>Git从何而来</h2><div class="columns">
<div class="column" style="width:40%;">
<p><img data-src="img/Torvalds.jpg" /></p>
</div><div class="column" style="width:60%;">
<p><br></p>
<ul>
<li><a href="http://www.voidcn.com/article/p-cjtmgqch-bne.html">Linux创始人Linus Torvalds访谈,Git的十年之旅</a></li>
<li><a href="https://www.liaoxuefeng.com/wiki/896043488029600/896202815778784">Git 诞生记</a></li>
<li><a href="https://blog.csdn.net/glory1234work2115/article/details/51277402">BitKeeper与Git的恩怨情仇</a></li>
</ul>
</div>
</div></section><section id="git去往何处" class="title-slide slide level2"><h2>Git去往何处</h2><div class="columns">
<div class="column" style="width:40%;">
<p><img data-src="img/Hamano.jpg" /></p>
</div><div class="column" style="width:60%;">
<p><br></p>
<ul>
<li>2005年7月26日开始,Torvalds把Git托付给了一位日本人:<a href="https://en.wikipedia.org/wiki/Junio_Hamano">Junio Hamano</a></li>
<li>Torvalds 2012 年说过自己一生最大的成功之一就包括把git托付给Hamano</li>
<li>Hamano现在google,他的github帐号为:<a href="https://github.com/gitster">gitster</a></li>
</ul>
</div>
</div></section><section id="官方specification" class="title-slide slide level2"><h2>官方Specification</h2><ul>
<li><a href="https://www.kernel.org/pub/software/scm/git/docs/">Git Man Page</a>: 即: git help</li>
<li><a href="https://www.kernel.org/pub/software/scm/git/docs/user-manual.html">Git User Manual</a></li>
<li>Git Tutorial
<ul>
<li><a href="https://www.kernel.org/pub/software/scm/git/docs/gittutorial.html">Part1</a> – 即 man gittutorial</li>
<li><a href="https://www.kernel.org/pub/software/scm/git/docs/gittutorial-2.html">Part2</a> – 即 man gittutorial-2</li>
</ul></li>
<li><a href="https://www.kernel.org/pub/software/scm/git/docs/howto/">How to</a></li>
</ul></section><section id="book" class="title-slide slide level2"><h2>Book</h2><ul>
<li>Pro Git
<ul>
<li>第2版:<a href="http://git-scm.com/book/zh/v2">中文官方在线版</a>、<a href="http://www.kancloud.cn/kancloud/progit">中文国内在线版</a>、<a href="http://git-scm.com/book/en/v2">英文官方在线版</a></li>
<li>第1版:<a href="http://git-scm.com/book/zh/v1">中文官方在线版</a>、<a href="http://git.oschina.net/progit/">中文国内在线版</a></li>
</ul></li>
<li><a href="http://gitbook.liuhui998.com/index.html">Git Community Book 中文版</a></li>
<li><a href="https://book.douban.com/subject/3405742/">Version Control with Git,《Git版本控制》</a></li>
<li><a href="http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000">git简明教程</a></li>
</ul></section><section id="website" class="title-slide slide level2"><h2>Website</h2><ul>
<li><a href="http://git-scm.com">git-scm.com</a></li>
<li><a href="https://en.wikipedia.org/wiki/Git_(software)">git 维基百科</a></li>
<li><a href="http://git.wiki.kernel.org">git SCM wiki</a> – 2011年已停止更新</li>
<li>其他
<ul>
<li><a href="https://boxueio.com/series/git-essential">在开发工作中引入git版本控制</a> :10节课,有视频,有文档,适合入门</li>
</ul></li>
</ul></section><section id="github上git的卓越组织" class="title-slide slide level2"><h2>github上Git的卓越组织</h2><ul>
<li><a href="https://github.com/git">git</a>:
<ul>
<li>目前有<a href="https://github.com/orgs/git/people">17位成员</a>,牵头人 <a href="https://github.com/schacon">Scott Chacon</a>,他们充当管理者和传教士的角色</li>
<li>比较重要的贡献是:
<ul>
<li>维护git源码
<ul>
<li><del>Hamano(gitster)并没有加入到这个Orgnization中,而只是fork到自己账号下,然后PR到 git/git,看来gitster只是想当程序员,不想当管理者和传教士——大概源于日本人和中国人类似,都比较低调。</del></li>
<li>Hamano 现在已经加入此组织</li>
</ul></li>
<li>管理和维护 <a href="http://git-scm.com">git-scm.com</a> 网站</li>
</ul></li>
</ul></li>
<li><a href="https://github.com/progit">progit</a>
<ul>
<li>目前有<a href="https://github.com/orgs/progit/people">18位成员</a>,牵头人 <a href="https://github.com/schacon">Scott Chacon</a> 和 <a href="https://github.com/ben">Ben Straub</a>,两人目前都供职于github公司,其他人多是从事翻译工作。</li>
<li>比较重要的贡献
<ul>
<li>写了《Pro git》这本书,此书被翻译成多种语言(<a href="https://git-scm.com/book/zh">中文版</a>),被奉为经典。</li>
</ul></li>
</ul></li>
</ul></section></section>
<section><section id="git-常用命令" class="title-slide slide level1"><h1>Git 常用命令</h1></section><section id="section" class="title-slide slide level2"><h2></h2><div class="sourceCode" id="cb1"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb1-1" title="1">$ <span class="fu">git</span> help</a>
<a class="sourceLine" id="cb1-2" title="2"> <span class="ex">add</span> Add file contents to the index</a>
<a class="sourceLine" id="cb1-3" title="3"> <span class="ex">bisect</span> Find by binary search the change that introduced a bug</a>
<a class="sourceLine" id="cb1-4" title="4"> <span class="ex">branch</span> List, create, or delete branches</a>
<a class="sourceLine" id="cb1-5" title="5"> <span class="ex">checkout</span> Checkout a branch or paths to the working tree</a>
<a class="sourceLine" id="cb1-6" title="6"> <span class="ex">clone</span> Clone a repository into a new directory</a>
<a class="sourceLine" id="cb1-7" title="7"> <span class="ex">commit</span> Record changes to the repository</a>
<a class="sourceLine" id="cb1-8" title="8"> <span class="fu">diff</span> Show changes between commits, commit and working tree, etc</a>
<a class="sourceLine" id="cb1-9" title="9"> <span class="ex">fetch</span> Download objects and refs from another repository</a>
<a class="sourceLine" id="cb1-10" title="10"> <span class="fu">grep</span> Print lines matching a pattern</a>
<a class="sourceLine" id="cb1-11" title="11"> <span class="ex">init</span> Create an empty Git repository or reinitialize an existing one</a>
<a class="sourceLine" id="cb1-12" title="12"> <span class="ex">log</span> Show commit logs</a>
<a class="sourceLine" id="cb1-13" title="13"> <span class="ex">merge</span> Join two or more development histories together</a>
<a class="sourceLine" id="cb1-14" title="14"> <span class="fu">mv</span> Move or rename a file, a directory, or a symlink</a>
<a class="sourceLine" id="cb1-15" title="15"> <span class="ex">pull</span> Fetch from and integrate with another repository or local branch</a>
<a class="sourceLine" id="cb1-16" title="16"> <span class="ex">push</span> Update remote refs along with associated objects</a>
<a class="sourceLine" id="cb1-17" title="17"> <span class="ex">rebase</span> Forward-port local commits to the updated upstream head</a>
<a class="sourceLine" id="cb1-18" title="18"> <span class="ex">reset</span> Reset current HEAD to the specified state</a>
<a class="sourceLine" id="cb1-19" title="19"> <span class="fu">rm</span> Remove files from the working tree and from the index</a>
<a class="sourceLine" id="cb1-20" title="20"> <span class="ex">show</span> Show various types of objects</a>
<a class="sourceLine" id="cb1-21" title="21"> <span class="ex">status</span> Show the working tree status</a>
<a class="sourceLine" id="cb1-22" title="22"> <span class="ex">tag</span> Create, list, delete or verify a tag object signed with GPG</a></code></pre></div></section><section id="practice" class="title-slide slide level2"><h2>Practice</h2><blockquote>
<p>快速记忆,请写出至少5个git的命令</p>
</blockquote></section><section id="git的逻辑分区及几个关键命令" class="title-slide slide level2"><h2>Git的逻辑分区及几个关键命令</h2><p><img src="img/git-logic-field.png" width="70%" /></p></section><section id="practice-1" class="title-slide slide level2"><h2>Practice</h2><blockquote>
<p>请绘出上页的图</p>
</blockquote></section></section>
<section><section id="git-my-diary" class="title-slide slide level1"><h1>Git my diary</h1><p>一个完整的日记示例</p></section><section id="最基本的两个配置name-和-email" class="title-slide slide level2"><h2>最基本的两个配置:name 和 email</h2><div class="sourceCode" id="cb2"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb2-1" title="1">$ <span class="fu">git</span> config --global user.name wkevin</a>
<a class="sourceLine" id="cb2-2" title="2">$ <span class="fu">git</span> config --global user.emal [email protected]</a></code></pre></div></section><section id="创建一个文件夹并写一篇日记" class="title-slide slide level2"><h2>创建一个文件夹并写一篇日记</h2><div class="sourceCode" id="cb3"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb3-1" title="1"><span class="ex">MBP</span>:demo wangkevin$ mkdir mydiary</a>
<a class="sourceLine" id="cb3-2" title="2"><span class="ex">MBP</span>:demo wangkevin$ cd mydiary</a>
<a class="sourceLine" id="cb3-3" title="3">$ <span class="fu">cat</span> <span class="op">></span>diary.md</a>
<a class="sourceLine" id="cb3-4" title="4"><span class="co"># Diary</span></a>
<a class="sourceLine" id="cb3-5" title="5"></a>
<a class="sourceLine" id="cb3-6" title="6"><span class="co">## 2016.1.31</span></a>
<a class="sourceLine" id="cb3-7" title="7">回家过年^<span class="ex">C</span></a>
<a class="sourceLine" id="cb3-8" title="8">$ <span class="fu">ls</span></a>
<a class="sourceLine" id="cb3-9" title="9"><span class="ex">diary.md</span></a>
<a class="sourceLine" id="cb3-10" title="10">$ <span class="fu">cat</span> diary.md </a>
<a class="sourceLine" id="cb3-11" title="11"><span class="co"># Diary</span></a>
<a class="sourceLine" id="cb3-12" title="12"></a>
<a class="sourceLine" id="cb3-13" title="13"><span class="co">## 2016.1.31</span></a>
<a class="sourceLine" id="cb3-14" title="14">回家过年</a></code></pre></div></section><section id="git-init-在文件夹中创建git库" class="title-slide slide level2"><h2>git init 在文件夹中创建git库</h2><div class="sourceCode" id="cb4"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb4-1" title="1">$ <span class="fu">git</span> init</a>
<a class="sourceLine" id="cb4-2" title="2"><span class="ex">Initialized</span> empty Git repository in /Users/kevin/workspace/demo/mydiary/.git/</a></code></pre></div></section><section id="和svn有.svn类似git也有.git" class="title-slide slide level2"><h2>和SVN有.svn类似,git也有.git</h2><div class="sourceCode" id="cb5"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb5-1" title="1">$ <span class="fu">ls</span> -a</a>
<a class="sourceLine" id="cb5-2" title="2"><span class="bu">.</span> <span class="ex">..</span> .git diary.md</a>
<a class="sourceLine" id="cb5-3" title="3">$ <span class="fu">ls</span> .git</a>
<a class="sourceLine" id="cb5-4" title="4"><span class="ex">HEAD</span> config hooks objects</a>
<a class="sourceLine" id="cb5-5" title="5"><span class="ex">branches</span> description info refs</a>
<a class="sourceLine" id="cb5-6" title="6">$ <span class="fu">cat</span> .git/config</a>
<a class="sourceLine" id="cb5-7" title="7">[<span class="ex">core</span>]</a>
<a class="sourceLine" id="cb5-8" title="8"> <span class="ex">repositoryformatversion</span> = 0</a>
<a class="sourceLine" id="cb5-9" title="9"> <span class="ex">filemode</span> = true</a>
<a class="sourceLine" id="cb5-10" title="10"> <span class="ex">bare</span> = false</a>
<a class="sourceLine" id="cb5-11" title="11"> <span class="ex">logallrefupdates</span> = true</a>
<a class="sourceLine" id="cb5-12" title="12"> <span class="ex">ignorecase</span> = true</a>
<a class="sourceLine" id="cb5-13" title="13"> <span class="ex">precomposeunicode</span> = true</a></code></pre></div></section><section id="git-status-查看当前状态" class="title-slide slide level2"><h2>git status 查看当前状态</h2><div class="sourceCode" id="cb6"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb6-1" title="1">$ <span class="fu">git</span> status</a>
<a class="sourceLine" id="cb6-2" title="2"><span class="ex">On</span> branch master</a>
<a class="sourceLine" id="cb6-3" title="3"></a>
<a class="sourceLine" id="cb6-4" title="4"><span class="ex">Initial</span> commit</a>
<a class="sourceLine" id="cb6-5" title="5"></a>
<a class="sourceLine" id="cb6-6" title="6"><span class="ex">Untracked</span> files:</a>
<a class="sourceLine" id="cb6-7" title="7"> <span class="kw">(</span><span class="ex">use</span> <span class="st">"git add <file>..."</span> to include in what will be committed<span class="kw">)</span></a>
<a class="sourceLine" id="cb6-8" title="8"></a>
<a class="sourceLine" id="cb6-9" title="9"> <span class="ex">diary.md</span></a>
<a class="sourceLine" id="cb6-10" title="10"></a>
<a class="sourceLine" id="cb6-11" title="11"><span class="ex">nothing</span> added to commit but untracked files present (use <span class="st">"git add"</span> to track)</a></code></pre></div>
<p>显示一个未被管控的文件(Untracked files) diary.md</p></section><section id="git-add-filename-将文件纳入管理" class="title-slide slide level2"><h2>git add filename 将文件纳入管理</h2><div class="sourceCode" id="cb7"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb7-1" title="1">$ <span class="fu">git</span> add diary.md </a></code></pre></div>
<p>filename 支持通配符,最常用的就是点(.)表示所有文件</p></section><section id="git-status" class="title-slide slide level2"><h2>git status</h2><div class="sourceCode" id="cb8"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb8-1" title="1">$ <span class="fu">git</span> status</a>
<a class="sourceLine" id="cb8-2" title="2"><span class="ex">On</span> branch master</a>
<a class="sourceLine" id="cb8-3" title="3"></a>
<a class="sourceLine" id="cb8-4" title="4"><span class="ex">Initial</span> commit</a>
<a class="sourceLine" id="cb8-5" title="5"></a>
<a class="sourceLine" id="cb8-6" title="6"><span class="ex">Changes</span> to be committed:</a>
<a class="sourceLine" id="cb8-7" title="7"> <span class="kw">(</span><span class="ex">use</span> <span class="st">"git rm --cached <file>..."</span> to unstage<span class="kw">)</span></a>
<a class="sourceLine" id="cb8-8" title="8"></a>
<a class="sourceLine" id="cb8-9" title="9"> <span class="ex">new</span> file: diary.md</a></code></pre></div>
<p>显示此文件待提交(to be committed),此时文件已经开始被git管理了,文件进入一种暂存状态(stage),如果想反悔可以用<code>git rm --cached</code>使其进入unstage状态</p></section><section id="git-status--sb" class="title-slide slide level2"><h2>git status -sb</h2><p>-s/–short 短模式</p>
<div class="sourceCode" id="cb9"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb9-1" title="1">$ <span class="fu">git</span> status -s</a>
<a class="sourceLine" id="cb9-2" title="2"><span class="ex">A</span> diary.md</a></code></pre></div>
<p>-b/–branch 显示分支</p>
<div class="sourceCode" id="cb10"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb10-1" title="1">$ <span class="fu">git</span> status -sb</a>
<a class="sourceLine" id="cb10-2" title="2"><span class="co">## Initial commit on master</span></a>
<a class="sourceLine" id="cb10-3" title="3"><span class="ex">A</span> diary.md</a></code></pre></div>
<p><code>git status</code>不带参数默认就是-b的,所以常和短模式合作,合并为一个sb,哈哈</p></section><section id="git-commit-将文件从暂存态提交入库" class="title-slide slide level2"><h2>git commit 将文件从暂存态提交入库</h2><div class="sourceCode" id="cb11"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb11-1" title="1">$ <span class="fu">git</span> commit</a>
<a class="sourceLine" id="cb11-2" title="2"><span class="ex">aster</span> (root-commit) <span class="ex">14dd781</span>] create mydiary</a>
<a class="sourceLine" id="cb11-3" title="3"> <span class="ex">1</span> file changed, 4 insertions(+)</a>
<a class="sourceLine" id="cb11-4" title="4"> <span class="ex">create</span> mode 100644 diary.md</a></code></pre></div>
<p>暂存就像回收站(删除前给你一个check的机会,多次操作放入回收站的文件可以一次清空),多次操作放入暂存,最后考虑成熟了,check OK了,再commit提交</p></section><section id="编辑-log-message" class="title-slide slide level2"><h2>编辑 log message</h2><div class="sourceCode" id="cb12"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb12-1" title="1"> <span class="ex">1</span> </a>
<a class="sourceLine" id="cb12-2" title="2"> <span class="ex">2</span> <span class="co"># Please enter the commit message for your changes. Lines starting</span></a>
<a class="sourceLine" id="cb12-3" title="3"> <span class="ex">3</span> <span class="co"># with '#' will be ignored, and an empty message aborts the commit.</span></a>
<a class="sourceLine" id="cb12-4" title="4"> <span class="ex">4</span> <span class="co"># On branch master</span></a>
<a class="sourceLine" id="cb12-5" title="5"> <span class="ex">5</span> <span class="co">#</span></a>
<a class="sourceLine" id="cb12-6" title="6"> <span class="ex">6</span> <span class="co"># Initial commit</span></a>
<a class="sourceLine" id="cb12-7" title="7"> <span class="ex">7</span> <span class="co">#</span></a>
<a class="sourceLine" id="cb12-8" title="8"> <span class="ex">8</span> <span class="co"># Changes to be committed:</span></a>
<a class="sourceLine" id="cb12-9" title="9"> <span class="ex">9</span> <span class="co"># new file: diary.md</span></a>
<a class="sourceLine" id="cb12-10" title="10"> <span class="ex">10</span> <span class="co">#</span></a></code></pre></div>
<p>执行 <code>git commit</code> 后会自动打开一个编辑器(编辑器是可配置的,以后再说怎么配置),比如 vi,进行提交log的撰写,保存退出即提交成功,不保存退出即放弃提交</p></section><section id="再查-git-status都已经提交干净了" class="title-slide slide level2"><h2>再查 git status,都已经提交干净了</h2><div class="sourceCode" id="cb13"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb13-1" title="1">$ <span class="fu">git</span> status</a>
<a class="sourceLine" id="cb13-2" title="2"><span class="ex">On</span> branch master</a>
<a class="sourceLine" id="cb13-3" title="3"><span class="ex">nothing</span> to commit, working directory clean</a>
<a class="sourceLine" id="cb13-4" title="4">$ <span class="fu">git</span> status -s</a></code></pre></div></section><section id="现在可以看log了" class="title-slide slide level2"><h2>现在可以看log了</h2><div class="sourceCode" id="cb14"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb14-1" title="1">$ <span class="fu">git</span> log</a>
<a class="sourceLine" id="cb14-2" title="2"><span class="ex">commit</span> 14dd7815fcf56c961e11c52e96e2fc3fbd7d0543</a>
<a class="sourceLine" id="cb14-3" title="3"><span class="ex">Author</span>: wkevin <span class="op"><</span>[email protected]<span class="op">></span></a>
<a class="sourceLine" id="cb14-4" title="4"><span class="ex">Date</span>: Sun Jan 31 11:39:55 2016 +0800</a>
<a class="sourceLine" id="cb14-5" title="5"></a>
<a class="sourceLine" id="cb14-6" title="6"> <span class="ex">create</span> mydiary</a></code></pre></div></section><section id="section-1" class="title-slide slide level2"><h2></h2><p>每天可以随时写日记、随时<code>git add</code>、适时<code>git commit</code>,经过一段时间,你的diary库就越来越让你爱不释手了</p>
<div class="sourceCode" id="cb15"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb15-1" title="1">$ <span class="fu">git</span> log</a>
<a class="sourceLine" id="cb15-2" title="2"><span class="ex">commit</span> 67840e1813af1084abd5d07d2e2a2e185c679f09</a>
<a class="sourceLine" id="cb15-3" title="3"><span class="ex">Author</span>: wkevin <span class="op"><</span>[email protected]<span class="op">></span></a>
<a class="sourceLine" id="cb15-4" title="4"><span class="ex">Date</span>: Sun Jan 31 12:20:26 2016 +0800</a>
<a class="sourceLine" id="cb15-5" title="5"></a>
<a class="sourceLine" id="cb15-6" title="6"> <span class="ex">2.2</span>日记</a>
<a class="sourceLine" id="cb15-7" title="7"></a>
<a class="sourceLine" id="cb15-8" title="8"><span class="ex">commit</span> bf36ab9b0d489a2eda911be9e01bddc395fc29e0</a>
<a class="sourceLine" id="cb15-9" title="9"><span class="ex">Author</span>: wkevin <span class="op"><</span>[email protected]<span class="op">></span></a>
<a class="sourceLine" id="cb15-10" title="10"><span class="ex">Date</span>: Sun Jan 31 12:19:33 2016 +0800</a>
<a class="sourceLine" id="cb15-11" title="11"></a>
<a class="sourceLine" id="cb15-12" title="12"> <span class="ex">2.1</span>的日记</a>
<a class="sourceLine" id="cb15-13" title="13"></a>
<a class="sourceLine" id="cb15-14" title="14"><span class="ex">commit</span> 14dd7815fcf56c961e11c52e96e2fc3fbd7d0543</a>
<a class="sourceLine" id="cb15-15" title="15"><span class="ex">Author</span>: wkevin <span class="op"><</span>[email protected]<span class="op">></span></a>
<a class="sourceLine" id="cb15-16" title="16"><span class="ex">Date</span>: Sun Jan 31 11:39:55 2016 +0800</a>
<a class="sourceLine" id="cb15-17" title="17"></a>
<a class="sourceLine" id="cb15-18" title="18"> <span class="ex">create</span> mydiary</a></code></pre></div>
<p>git 和 svn 不同,没有一个数字递增的节点号,而是一串40Bytes的哈希字符,指定一个提交只需要给出这个字符串即可,当然不能让你每次都把40个字符全输入一遍,只需要输入够区分提交的即可(一般是前7位),如果咱的库规模还很小,前4位也行哦(上文中的“6784”)</p></section><section id="practice-2" class="title-slide slide level2"><h2>Practice</h2><blockquote>
<p>请简要的按顺序写出上面例子中用到的git命令</p>
</blockquote></section></section>
<section><section id="git-revesion" class="title-slide slide level1"><h1>Git Revesion</h1></section><section id="git-revision-的描述" class="title-slide slide level2"><h2>git revision 的描述</h2><ul>
<li><code><sha1></code>: e.g. dae86e</li>
<li><code><describeOutput></code>: e.g. v1.2.3</li>
<li><code><refname></code>: e.g. HEAD,master, heads/master, refs/heads/master</li>
<li><code>@</code> : HEAD的简写</li>
<li><code><refname>@{<date>}</code>: data日期之前的第一个revision</li>
<li><code><refname>@{<n>}</code>: 第n-th个revision
<ul>
<li>git log 出的1-st revision在这里算 2-nd</li>
</ul></li>
<li><code><rev>^</code>: e.g. HEAD^, v1.2.3^, 表示 rev的前一个revision</li>
<li><code><rev>~<n></code>: e.g. HEAD~3, master~3,去掉n个,取下一个
<ul>
<li>git log 出的1-st revision开始去掉</li>
</ul></li>
</ul>
<div class="foottext">
<br><br>详细:<code>git help revisions</code> 或 <code>man gitrevisions</code>
</div></section><section id="git-revision-range-的描述" class="title-slide slide level2"><h2>git revision range 的描述</h2><ul>
<li><code><rev></code>: 从rev到结束的所有revision都包括进来</li>
<li><code>^<rev></code>: 从rev到结束的所有revision都抛弃掉</li>
<li><code><rev1> <rev2></code>: “rev1到结束”和“rev2到结束”取并集,即:rev1或rev2到结束最多的那个range</li>
<li><code><rev1> ^<rev2></code> == <code>^<rev2> <rev1></code>: “rev1到结束”和“rev2到结束”取并集,即:rev1 和 rev2 之间,但不包括rev2,rev1和rev2无时间先后</li>
<li><code><rev1>..<rev2></code>: 从rev2往前,到rev1(但不包括rev1)或rev1所在的分支的交汇点,rev1或rev1与rev2分支交汇点要在rev2的时间前面</li>
<li><code><rev1>...<rev2></code>:</li>
<li><code><rev>^@</code>: rev的所有parent,不包括 rev</li>
<li><code><rev>^!</code>: 仅rev</li>
</ul>
<div class="foottext">
<br><br>详细:<code>git help revisions</code> 或 <code>man gitrevisions</code>
</div></section><section id="practice-3" class="title-slide slide level2"><h2>Practice</h2><div class="fragment">
只看 zte 分支的 revision
</div>
<div class="fragment">
<div class="sourceCode" id="cb16"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb16-1" title="1">$ <span class="fu">git</span> log zte</a></code></pre></div>
</div>
<div class="fragment">
从上周三的 revision 开始看
</div>
<div class="fragment">
<div class="sourceCode" id="cb17"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb17-1" title="1">$ <span class="fu">git</span> log @<span class="dt">{2016-7-13}</span></a></code></pre></div>
</div>
<div class="fragment">
不看近10次的 revision
</div>
<div class="fragment">
<div class="sourceCode" id="cb18"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb18-1" title="1">$ <span class="fu">git</span> log master~10</a></code></pre></div>
</div>
<div class="fragment">
<div class="sourceCode" id="cb19"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb19-1" title="1">$ <span class="fu">git</span> log master@<span class="dt">{12}</span></a></code></pre></div>
</div></section><section id="practice-4" class="title-slide slide level2"><h2>Practice</h2><div class="fragment">
只看近一个月的 revision
</div>
<div class="fragment">
<div class="sourceCode" id="cb20"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb20-1" title="1">$ <span class="fu">git</span> log ^@<span class="dt">{1month}</span> HEAD</a></code></pre></div>
</div>
<div class="fragment">
<div class="sourceCode" id="cb21"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb21-1" title="1">$ <span class="fu">git</span> log HEAD ^@<span class="dt">{1month}</span></a></code></pre></div>
</div>
<div class="fragment">
<div class="sourceCode" id="cb22"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb22-1" title="1">$ <span class="fu">git</span> log @<span class="dt">{1month}</span>..</a></code></pre></div>
</div>
<div class="fragment">
<div class="sourceCode" id="cb23"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb23-1" title="1">$ <span class="fu">git</span> log ..@<span class="dt">{1month}</span> //WRONG</a></code></pre></div>
</div></section></section>
<section><section id="git-config" class="title-slide slide level1"><h1>git config</h1></section><section id="location" class="title-slide slide level2"><h2>location</h2><table>
<thead>
<tr class="header">
<th>command</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>git config [–local]</td>
<td>配置项保存到当前git项目(./.git)<br>仅本项目有效默认</td>
</tr>
<tr class="even">
<td>git config –system</td>
<td>配置项保存到系统(/etc/gitconfig)<br>所有git项目有效</td>
</tr>
<tr class="odd">
<td>git config –global</td>
<td>配置项保存到用户根目录(~/.git/config)<br>当前用户的所有项目有效</td>
</tr>
<tr class="even">
<td>git config –file</td>
<td>配置项保存到指定文件</td>
</tr>
</tbody>
</table></section><section id="alias" class="title-slide slide level2"><h2>alias</h2><p align="left" style="margin-left:5%">
语法
</p>
<div class="sourceCode" id="cb24"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb24-1" title="1">$ <span class="fu">git</span> config --global alias.命令缩写 原命令+参数</a></code></pre></div>
<p align="left" style="margin-left:5%">
举例
</p>
<div class="sourceCode" id="cb25"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb25-1" title="1">$ <span class="fu">git</span> config --global alias.st <span class="st">"status -sb"</span></a></code></pre></div>
<p align="left" style="margin-left:5%">
使用缩写
</p>
<div class="sourceCode" id="cb26"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb26-1" title="1">$ <span class="fu">git</span> st</a>
<a class="sourceLine" id="cb26-2" title="2"><span class="co">## master</span></a>
<a class="sourceLine" id="cb26-3" title="3"> <span class="ex">M</span> diary.md</a></code></pre></div>
<p>别名(alias)是linux系统的基本概念,在git中也如鱼得水。</p></section><section id="我的常用别名" class="title-slide slide level2"><h2>我的常用别名</h2><div class="sourceCode" id="cb27"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb27-1" title="1">$ <span class="fu">git</span> config -l <span class="kw">|</span> <span class="fu">grep</span> alias</a>
<a class="sourceLine" id="cb27-2" title="2"><span class="ex">alias.st</span>=status</a>
<a class="sourceLine" id="cb27-3" title="3"><span class="ex">alias.co</span>=checkout</a>
<a class="sourceLine" id="cb27-4" title="4"><span class="ex">alias.br</span>=branch -avv</a>
<a class="sourceLine" id="cb27-5" title="5"><span class="ex">alias.rt</span>=remote -vv</a>
<a class="sourceLine" id="cb27-6" title="6"><span class="ex">alias.l</span>=log --format=format:<span class="st">'%C(auto) %h | %ai | %Cred %an %Cgreen %s'</span> --date=local</a>
<a class="sourceLine" id="cb27-7" title="7"><span class="ex">alias.lg</span>=log --format=format:<span class="st">'%C(auto) %h | %ai | %ci | %Cred %an %Cgreen %s'</span></a>
<a class="sourceLine" id="cb27-8" title="8"><span class="ex">alias.tg</span>=log --format=format:<span class="st">'%C(auto) %h | %ai | %ci | %d | %Cred %an %Cgreen %s'</span> --simplify-by-decoration</a>
<a class="sourceLine" id="cb27-9" title="9"><span class="ex">alias.cl</span>=clone</a>
<a class="sourceLine" id="cb27-10" title="10"><span class="ex">alias.si</span>=submodule init</a>
<a class="sourceLine" id="cb27-11" title="11"><span class="ex">alias.sa</span>=submodule add</a>
<a class="sourceLine" id="cb27-12" title="12"><span class="ex">alias.su</span>=submodule update</a>
<a class="sourceLine" id="cb27-13" title="13"><span class="ex">alias.ci</span>=commit</a>
<a class="sourceLine" id="cb27-14" title="14"><span class="ex">alias.sab</span>=submodule add -b master</a>
<a class="sourceLine" id="cb27-15" title="15"><span class="ex">alias.sur</span>=submodule update --remote</a>
<a class="sourceLine" id="cb27-16" title="16"><span class="ex">alias.tags</span>=log --tags --simplify-by-decoration --pretty=<span class="st">"format:%ci %d"</span></a>
<a class="sourceLine" id="cb27-17" title="17"><span class="ex">alias.dt</span>=difftool</a></code></pre></div></section></section>
<section><section id="git-add" class="title-slide slide level1"><h1>git add</h1></section><section id="原理图" class="title-slide slide level2"><h2>原理图</h2><embed src="img/git-add.svg" type="image/svg+xml" style="background-color:white" /></section><section id="focal-point" class="title-slide slide level2"><h2>Focal Point</h2><ul>
<li>git add onefile</li>
<li>git add .</li>
<li>git add onefolder/.</li>
</ul></section><section id="stage" class="title-slide slide level2"><h2>stage</h2><ol type="1">
<li>名词:舞台、讲台,比如:戏剧表演的舞台、国际政治的舞台;阶段,类似phase,比如:stage one/two意思是第一/二阶段,three-stage rocket意思是三级火箭</li>
<li>动词:上演、举行、组织,类似play、organize,比如:stage a football match,举办足球赛</li>
</ol>
<p><br><br><br />
stage本身并没有暂存的意思,git中可以理解为把文件放到一个舞台上上演一下,进而文件进入到一个新的阶段。——用这个词可以说是一箭三雕</p></section><section id="git-help-stage" class="title-slide slide level2"><h2>git help stage</h2><div class="sourceCode" id="cb28"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb28-1" title="1"><span class="va">$git</span> <span class="bu">help</span> stage</a>
<a class="sourceLine" id="cb28-2" title="2"></a>
<a class="sourceLine" id="cb28-3" title="3"><span class="ex">GIT-STAGE</span>(1) <span class="ex">Git</span> Manual GIT-STAGE(1)</a>
<a class="sourceLine" id="cb28-4" title="4"><span class="ex">NAME</span></a>
<a class="sourceLine" id="cb28-5" title="5"> <span class="ex">git-stage</span> - Add file contents to the staging area</a>
<a class="sourceLine" id="cb28-6" title="6"><span class="ex">SYNOPSIS</span></a>
<a class="sourceLine" id="cb28-7" title="7"> <span class="fu">git</span> stage args...</a>
<a class="sourceLine" id="cb28-8" title="8"><span class="ex">DESCRIPTION</span></a>
<a class="sourceLine" id="cb28-9" title="9"> <span class="ex">This</span> is a synonym for git-add(1)<span class="bu">.</span> <span class="ex">Please</span> refer to the documentation of that command.</a></code></pre></div>
<ul>
<li>help中可以发现: <code>git stage</code> 是同义于 <code>git add</code></li>
<li><strong>staging area</strong>: 舞台区、阶段区、进而翻译为暂存区 —— 如果让我翻译,我会译为:<strong>检视区</strong>。</li>
</ul></section><section id="暂存区-回收站" class="title-slide slide level2"><h2>暂存区 ~ 回收站</h2><ul>
<li>把文件放在回收站是给操作人一个检视的机会和反悔的机会,操作妥当后再彻底删除,彻底删除后再想反悔就要费劲了。</li>
<li>git的staging area也是给用户一个<strong>检视的机会</strong>和<strong>反悔的机会</strong>,用户可以:
<ul>
<li>使用<code>git add</code>或<code>git stage</code>命令随时向SA增加文件,和回收站不同的是后进入SA的文件会覆盖前面进入的</li>
<li>使用<code>git checkout</code>命令随时从SA反悔,文件会从SA移除,是否覆盖</li>
</ul></li>
</ul></section><section id="gitignore" class="title-slide slide level2"><h2>.gitignore</h2><ul>
<li>当前目录下的忽略文件、目录的列表,如:编译过程文件……</li>
<li>可以存在与git项目的根目录和子目录下,每个文件只影响该目录下的文件和子目录</li>
<li>手工写,没有自动生成</li>
<li>支持shell通配符,如:<code>*</code></li>
<li><code>#</code>开头表示注释行</li>
<li><code>!</code>开头的表示取反</li>
</ul>
<div class="sourceCode" id="cb29"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb29-1" title="1"><span class="ex">linux.git</span>$ cat .gitignore </a>
<a class="sourceLine" id="cb29-2" title="2"><span class="ex">12</span> .*</a>
<a class="sourceLine" id="cb29-3" title="3"><span class="ex">13</span> *.o</a>
<a class="sourceLine" id="cb29-4" title="4"><span class="ex">14</span> *.o.*</a>
<a class="sourceLine" id="cb29-5" title="5"><span class="ex">15</span> *.a</a>
<a class="sourceLine" id="cb29-6" title="6"><span class="ex">16</span> *.s</a>
<a class="sourceLine" id="cb29-7" title="7"><span class="ex">17</span> *.ko</a>
<a class="sourceLine" id="cb29-8" title="8"><span class="ex">18</span> *.so</a></code></pre></div></section></section>
<section><section id="git-commit" class="title-slide slide level1"><h1>git commit</h1></section><section id="focal-point-1" class="title-slide slide level2"><h2>Focal Point</h2><ul>
<li>git commit -a/–all : 提交所有已暂存、未暂存、未追踪的文件</li>
<li>git commit -m “xxx”</li>
<li>git commit : 没有 -m “xxx”, git 会调用一个外部编辑器
<ul>
<li>编辑器保存退出 && message不为空: 则算一次成功的提交</li>
<li>不保存退出 || message为空: 提交作废</li>
</ul></li>
</ul></section><section id="ubuntu-的编辑器" class="title-slide slide level2"><h2>Ubuntu 的编辑器</h2><div class="sourceCode" id="cb30"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb30-1" title="1">$ <span class="ex">update-alternatives</span> --config editor</a>
<a class="sourceLine" id="cb30-2" title="2"><span class="ex">There</span> are 8 choices for the alternative editor (providing /usr/bin/editor)<span class="ex">.</span></a>
<a class="sourceLine" id="cb30-3" title="3"></a>
<a class="sourceLine" id="cb30-4" title="4"> <span class="ex">Selection</span> Path Priority Status</a>
<a class="sourceLine" id="cb30-5" title="5"><span class="ex">------------------------------------------------------------</span></a>
<a class="sourceLine" id="cb30-6" title="6"><span class="ex">*</span> 0 /usr/bin/vim.gnome 60 auto mode</a>
<a class="sourceLine" id="cb30-7" title="7"> <span class="ex">1</span> /bin/ed -100 manual mode</a>
<a class="sourceLine" id="cb30-8" title="8"> <span class="ex">2</span> /bin/nano 40 manual mode</a>
<a class="sourceLine" id="cb30-9" title="9"> <span class="ex">3</span> /usr/bin/vim.athena 50 manual mode</a>
<a class="sourceLine" id="cb30-10" title="10"> <span class="ex">4</span> /usr/bin/vim.basic 30 manual mode</a>
<a class="sourceLine" id="cb30-11" title="11"> <span class="ex">5</span> /usr/bin/vim.gnome 60 manual mode</a>
<a class="sourceLine" id="cb30-12" title="12"> <span class="ex">6</span> /usr/bin/vim.gtk 50 manual mode</a>
<a class="sourceLine" id="cb30-13" title="13"> <span class="ex">7</span> /usr/bin/vim.nox 40 manual mode</a>
<a class="sourceLine" id="cb30-14" title="14"> <span class="ex">8</span> /usr/bin/vim.tiny 10 manual mode</a>
<a class="sourceLine" id="cb30-15" title="15"></a>
<a class="sourceLine" id="cb30-16" title="16"><span class="ex">Press</span> enter to keep the current choice[*], or type selection number: </a></code></pre></div></section></section>
<section><section id="git-rm" class="title-slide slide level1"><h1>git rm</h1></section><section id="删除文件" class="title-slide slide level2"><h2>删除文件</h2><ul>
<li>直接使用 rm 删除,会让 git 认为文件丢失(missing状态)</li>
<li>git rm 才能让 git 争取识别用户意图</li>
<li>git rm 操作后文件本地工作目录中的文件即被删除, git commit 时删除对象库中的。</li>
</ul></section></section>
<section><section id="git-log" class="title-slide slide level1"><h1>git log</h1></section><section id="git-shortlog" class="title-slide slide level2"><h2>git shortlog</h2><div class="sourceCode" id="cb31"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb31-1" title="1"><span class="ex">GitChat.git</span>$ git shortlog</a>
<a class="sourceLine" id="cb31-2" title="2"><span class="ex">Kevin</span> Wang (3)<span class="bu">:</span></a>
<a class="sourceLine" id="cb31-3" title="3"> <span class="ex">create</span></a>
<a class="sourceLine" id="cb31-4" title="4"> 增加:<span class="st">"git在哪里"</span>和<span class="st">"git for windows 咋用"</span> 章节</a>
<a class="sourceLine" id="cb31-5" title="5"> <span class="ex">add</span> git for windows 章节</a>
<a class="sourceLine" id="cb31-6" title="6"></a>
<a class="sourceLine" id="cb31-7" title="7"><span class="ex">wkevin</span> (36)<span class="bu">:</span></a>
<a class="sourceLine" id="cb31-8" title="8"> <span class="ex">github</span> desktop for windows snapshot</a>
<a class="sourceLine" id="cb31-9" title="9"> 在动车上写的:修改为<span class="ex">Round</span> x,增加了每个Round的插图。 虽然是春运,</a>
<a class="sourceLine" id="cb31-10" title="10"> 基本写完 <span class="ex">Round</span> 2 ,git log 部分</a>
<a class="sourceLine" id="cb31-11" title="11"> 写完 “## 我要能像<span class="ex">TortoiseSVN</span>那样左右两栏对比看diff”章节</a>
<a class="sourceLine" id="cb31-12" title="12"> 笔误: 缺少一个反括号</a>
<a class="sourceLine" id="cb31-13" title="13"> 笔误</a>
<a class="sourceLine" id="cb31-14" title="14"> <span class="ex">new</span> file: img/git-state-and-area.svg</a>
<a class="sourceLine" id="cb31-15" title="15"> 春节结束了,吃肉、喝酒、斗地主之余,带着酒劲继续写了一些,提交一下,很多地方还是</a>
<a class="sourceLine" id="cb31-16" title="16"> <span class="ex">1.</span>修改TOC的定义:空格使用<span class="st">'-'</span>替代 2.增加“分支”、“ssh”、“远程分支”‘rese</a>
<a class="sourceLine" id="cb31-17" title="17"> 增加“<span class="ex">git</span>分支之间的关系咋看”、“到哪里找开源项目”、“等章节, </a>
<a class="sourceLine" id="cb31-18" title="18"> <span class="ex">sublime</span>的markdown preview插件生成的headeranchor与markdowntoc插件生成</a></code></pre></div>
<ul>
<li>根据提交人分类</li>
<li>每次提交占1行</li>
<li>时间先旧后新</li>
</ul></section><section id="git-log-dateshort" class="title-slide slide level2"><h2>git log –date=short</h2><div class="sourceCode" id="cb32"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb32-1" title="1"><span class="ex">GitChat.git</span>$ git log HEAD^!</a>
<a class="sourceLine" id="cb32-2" title="2"><span class="ex">commit</span> 04e9afe4329f90d0c1dd42b0ac20f7b9324e33e6</a>
<a class="sourceLine" id="cb32-3" title="3"><span class="ex">Author</span>: wkevin <span class="op"><</span>[email protected]<span class="op">></span></a>
<a class="sourceLine" id="cb32-4" title="4"><span class="ex">Date</span>: Tue Jul 12 19:56:23 2016 +0800</a>
<a class="sourceLine" id="cb32-5" title="5"></a>
<a class="sourceLine" id="cb32-6" title="6"> 增加<span class="ex">Slides</span>功能</a></code></pre></div>
<div class="sourceCode" id="cb33"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb33-1" title="1"><span class="ex">GitChat.git</span>$ git log --date=short HEAD^!</a>
<a class="sourceLine" id="cb33-2" title="2"><span class="ex">commit</span> 04e9afe4329f90d0c1dd42b0ac20f7b9324e33e6</a>
<a class="sourceLine" id="cb33-3" title="3"><span class="ex">Author</span>: wkevin <span class="op"><</span>[email protected]<span class="op">></span></a>
<a class="sourceLine" id="cb33-4" title="4"><span class="ex">Date</span>: 2016-07-12</a>
<a class="sourceLine" id="cb33-5" title="5"></a>
<a class="sourceLine" id="cb33-6" title="6"> 增加<span class="ex">Slides</span>功能</a></code></pre></div></section><section id="git-log-prettyxxx" class="title-slide slide level2"><h2>git log –pretty=xxx</h2><div class="sourceCode" id="cb34"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb34-1" title="1"><span class="ex">GitChat.git</span>$ git log --pretty=oneline</a>
<a class="sourceLine" id="cb34-2" title="2"><span class="ex">04e9afe4329f90d0c1dd42b0ac20f7b9324e33e6</span> 增加Slides功能</a>
<a class="sourceLine" id="cb34-3" title="3"><span class="ex">ade6a93f4770d152348b615cbc923daa7bcc1781</span> 新增章节:push 错了,我要丢弃remote上的某个节点</a>
<a class="sourceLine" id="cb34-4" title="4"><span class="ex">145fedb470129987f86ff16f8f3ebf47b5a0a584</span> 增加章节:分支名能否用中文</a>
<a class="sourceLine" id="cb34-5" title="5"><span class="ex">9bdce19d503fb59377ed2058bdb4b98d87374cab</span> 笔误</a>
<a class="sourceLine" id="cb34-6" title="6"><span class="ex">513687920c881f938a8230e8288596a7905727ff</span> WWDC2016中刚刚宣布OS.X更名为macOS,本文即刻修改</a>
<a class="sourceLine" id="cb34-7" title="7"><span class="ex">b748256b246a11137fc82556fe8da96ec1567214</span> 增加章节:如何避免arc diff玷污现有节点; 如何创建只包含部分文件的评审单</a>
<a class="sourceLine" id="cb34-8" title="8"><span class="ex">d6efce6e8804ecb027762e0151ed071bc7d63b6d</span> 增加章节: arc diff的ubuntu安装</a>
<a class="sourceLine" id="cb34-9" title="9"><span class="ex">f8c101daaf75121dd4f1f1380b4dc5c1ed85cea0</span> Merge remote-tracking branch <span class="st">'zte/master'</span></a>
<a class="sourceLine" id="cb34-10" title="10"><span class="ex">9238c6940753e9560fb6a3c688f1c2d0d9135a72</span> 新增 Round8:git与phabricator</a>
<a class="sourceLine" id="cb34-11" title="11"><span class="ex">1631166cb86d7648e8a3aa98f51ea0fe5391f1e4</span> 增加:整理git的外网托管网站</a>
<a class="sourceLine" id="cb34-12" title="12"><span class="ex">5d200a32cb86d9818926eea8caf8d5da389ac30d</span> 新增:分支的合并(git merge)有哪几种场景,合并时如何处理分支中的“垃圾”log,把特性分支合入主干”和“把主干合入特性分支”有什么区别</a>
<a class="sourceLine" id="cb34-13" title="13"><span class="ex">11f41a52a099dd3114b54eb1878201c29893b3c2</span> 完善 git proxy 的描述</a>
<a class="sourceLine" id="cb34-14" title="14"><span class="ex">9d8d843db0a021fc8054b73e157d4a648e4d94bb</span> 使用 rawgit.com 展示</a></code></pre></div></section><section id="git-log-prettyshort" class="title-slide slide level2"><h2>git log –pretty=short</h2><div class="sourceCode" id="cb35"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb35-1" title="1"><span class="ex">GitChat.git</span>$ git log --pretty=short</a>
<a class="sourceLine" id="cb35-2" title="2"><span class="ex">commit</span> 04e9afe4329f90d0c1dd42b0ac20f7b9324e33e6</a>
<a class="sourceLine" id="cb35-3" title="3"><span class="ex">Author</span>: wkevin <span class="op"><</span>[email protected]<span class="op">></span></a>
<a class="sourceLine" id="cb35-4" title="4"></a>
<a class="sourceLine" id="cb35-5" title="5"> 增加<span class="ex">Slides</span>功能</a>
<a class="sourceLine" id="cb35-6" title="6"></a>
<a class="sourceLine" id="cb35-7" title="7"><span class="ex">commit</span> ade6a93f4770d152348b615cbc923daa7bcc1781</a>
<a class="sourceLine" id="cb35-8" title="8"><span class="ex">Author</span>: wkevin <span class="op"><</span>[email protected]<span class="op">></span></a>
<a class="sourceLine" id="cb35-9" title="9"></a>
<a class="sourceLine" id="cb35-10" title="10"> 新增章节:<span class="ex">push</span> 错了,我要丢弃remote上的某个节点</a>
<a class="sourceLine" id="cb35-11" title="11"></a>
<a class="sourceLine" id="cb35-12" title="12"><span class="ex">commit</span> 145fedb470129987f86ff16f8f3ebf47b5a0a584</a>
<a class="sourceLine" id="cb35-13" title="13"><span class="ex">Author</span>: wkevin <span class="op"><</span>[email protected]<span class="op">></span></a>
<a class="sourceLine" id="cb35-14" title="14"></a>
<a class="sourceLine" id="cb35-15" title="15"> 增加章节:分支名能否用中文</a></code></pre></div></section><section id="git-log-prettyformatexxx" class="title-slide slide level2"><h2>git log –pretty=formate:“xxx”</h2><ul>
<li>xxx:
<ul>
<li>%h:commit hash</li>
<li>%ai: author date</li>
<li>%an: author name</li>
<li>%ci: commit date</li>
<li>%cn: commit name</li>
<li>%s: log message</li>
</ul></li>
</ul>
<div class="sourceCode" id="cb36"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb36-1" title="1"><span class="ex">GitChat.git</span>$ git log --pretty=format:<span class="st">'%ad %an %s'</span></a>
<a class="sourceLine" id="cb36-2" title="2"><span class="ex">Tue</span> Jul 12 19:56:23 2016 +0800 wkevin 增加Slides功能</a>
<a class="sourceLine" id="cb36-3" title="3"><span class="ex">Fri</span> Jul 8 14:20:27 2016 +0800 wkevin 新增章节:push 错了,我要丢弃remote上的某个节点</a>
<a class="sourceLine" id="cb36-4" title="4"><span class="ex">Fri</span> Jul 8 09:56:16 2016 +0800 wkevin 增加章节:分支名能否用中文</a>
<a class="sourceLine" id="cb36-5" title="5"><span class="ex">Thu</span> Jul 7 13:46:02 2016 +0800 wkevin 笔误</a></code></pre></div></section><section id="git-config-global-alias.lg-log" class="title-slide slide level2"><h2>git config –global alias.lg “log …”</h2><div class="sourceCode" id="cb37"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb37-1" title="1"><span class="fu">git</span> config --global alias.lg <span class="st">"log --format=format:'%C(auto) %h | %ai | %ci | %Cred %an %Cgreen %s'"</span></a></code></pre></div>
<div class="sourceCode" id="cb38"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb38-1" title="1"><span class="ex">GitChat.git</span>$ git lg</a>
<a class="sourceLine" id="cb38-2" title="2"> <span class="ex">04e9afe</span> <span class="kw">|</span> <span class="ex">2016-07-12</span> 19:56:23 +0800 <span class="kw">|</span> <span class="ex">2016-07-12</span> 19:56:23 +0800 <span class="kw">|</span> <span class="ex">wkevin</span> 增加Slides功能</a>
<a class="sourceLine" id="cb38-3" title="3"> <span class="ex">ade6a93</span> <span class="kw">|</span> <span class="ex">2016-07-08</span> 14:20:27 +0800 <span class="kw">|</span> <span class="ex">2016-07-08</span> 14:20:27 +0800 <span class="kw">|</span> <span class="ex">wkevin</span> 新增章节:push 错了,我要丢弃remote上的某个节点</a>
<a class="sourceLine" id="cb38-4" title="4"> <span class="ex">145fedb</span> <span class="kw">|</span> <span class="ex">2016-07-08</span> 09:56:16 +0800 <span class="kw">|</span> <span class="ex">2016-07-08</span> 09:56:16 +0800 <span class="kw">|</span> <span class="ex">wkevin</span> 增加章节:分支名能否用中文</a>
<a class="sourceLine" id="cb38-5" title="5"> <span class="ex">9bdce19</span> <span class="kw">|</span> <span class="ex">2016-07-07</span> 13:46:02 +0800 <span class="kw">|</span> <span class="ex">2016-07-07</span> 13:46:02 +0800 <span class="kw">|</span> <span class="ex">wkevin</span> 笔误</a>
<a class="sourceLine" id="cb38-6" title="6"> <span class="ex">5136879</span> <span class="kw">|</span> <span class="ex">2016-06-14</span> 13:35:16 +0800 <span class="kw">|</span> <span class="ex">2016-06-14</span> 13:35:16 +0800 <span class="kw">|</span> <span class="ex">wkevin</span> WWDC2016中刚刚宣布OS.X更名为macOS,本文即刻修改</a>
<a class="sourceLine" id="cb38-7" title="7"> <span class="ex">b748256</span> <span class="kw">|</span> <span class="ex">2016-06-13</span> 15:14:08 +0800 <span class="kw">|</span> <span class="ex">2016-06-13</span> 15:14:08 +0800 <span class="kw">|</span> <span class="ex">wkevin</span> 增加章节:如何避免arc diff玷污现有节点; 如何创建只包含部分文件的评审单</a>
<a class="sourceLine" id="cb38-8" title="8"> <span class="ex">d6efce6</span> <span class="kw">|</span> <span class="ex">2016-06-13</span> 11:51:26 +0800 <span class="kw">|</span> <span class="ex">2016-06-13</span> 11:51:26 +0800 <span class="kw">|</span> <span class="ex">wkevin</span> 增加章节: arc diff的ubuntu安装</a>
<a class="sourceLine" id="cb38-9" title="9"> <span class="ex">f8c101d</span> <span class="kw">|</span> <span class="ex">2016-06-08</span> 17:21:39 +0800 <span class="kw">|</span> <span class="ex">2016-06-08</span> 17:21:39 +0800 <span class="kw">|</span> <span class="ex">wkevin</span> Merge remote-tracking branch <span class="st">'zte/master'</span></a>
<a class="sourceLine" id="cb38-10" title="10"> <span class="ex">9238c69</span> <span class="kw">|</span> <span class="ex">2016-06-08</span> 17:19:33 +0800 <span class="kw">|</span> <span class="ex">2016-06-08</span> 17:19:33 +0800 <span class="kw">|</span> <span class="ex">wkevin</span> 新增 Round8:git与phabricator</a>
<a class="sourceLine" id="cb38-11" title="11"> <span class="ex">1631166</span> <span class="kw">|</span> <span class="ex">2016-05-25</span> 16:09:06 +0800 <span class="kw">|</span> <span class="ex">2016-05-25</span> 16:09:06 +0800 <span class="kw">|</span> <span class="ex">wkevin</span> 增加:整理git的外网托管网站</a></code></pre></div></section><section id="gitk" class="title-slide slide level2"><h2>gitk</h2><p><img data-src="img/gitk.png" /></p></section></section>
<section><section id="git-diff" class="title-slide slide level1"><h1>git diff</h1></section><section id="比较对象" class="title-slide slide level2"><h2>比较对象</h2><table>
<thead>
<tr class="header">
<th>命令</th>
<th>比较对象</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><code>git diff</code></td>
<td>工作目录~索引区</td>
</tr>
<tr class="even">
<td><code>git diff --cached</code></td>
<td>索引区~对象库</td>
</tr>
<tr class="odd">
<td><code>git diff <rev></code></td>
<td>工作目录~rev</td>
</tr>
<tr class="even">
<td><code>git diff <rev1> <rev2></code><br><code>git diff <rev1>..<rev2></code></td>
<td>rev1~rev2</td>
</tr>
<tr class="odd">
<td></td>
<td></td>
</tr>
</tbody>
</table></section><section id="结果显示" class="title-slide slide level2"><h2>结果显示</h2><table>
<thead>
<tr class="header">
<th>命令</th>
<th>结果显示</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><code>git diff</code></td>
<td>结果是变更文件,和patch形式的文本</td>
</tr>
<tr class="even">
<td><code>git diff --stat</code></td>
<td>结果只显示变更文件,和变更的内容幅度</td>
</tr>
<tr class="odd">
<td><code>git diff --name-only</code></td>
<td>结果只显示变更文件的文件名</td>
</tr>
<tr class="even">
<td><code>git diff --name-stat</code></td>
<td>结果显示变更文件的文件名,和增删改的状态</td>
</tr>
<tr class="odd">
<td></td>
<td></td>
</tr>
</tbody>
</table></section><section id="linux-diff" class="title-slide slide level2"><h2>linux diff</h2><p>diff f1 f2 == f1与f2之间的差异 == f1 -> f2 的变化过程</p>
<p><br></p>
<table>
<thead>
<tr class="header">
<th>diff shell 命令</th>
<th>3种输出格式</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>$ diff f1 f2</td>
<td>正常格式(normal diff)</td>
</tr>
<tr class="even">
<td>$ diff f1 f2 -c</td>
<td>上下文格式(context diff)</td>
</tr>
<tr class="odd">
<td>$ diff f1 f2 -u</td>
<td>合并格式(unified diff)</td>
</tr>
<tr class="even">
<td></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>diff f1 f2 =X= diff f2 f1</strong></p></section><section id="linux-diff-2" class="title-slide slide level2"><h2>linux diff 2</h2><p>两个文件: 1.txt、2.txt,并列显示内容如下:</p>
<div class="sourceCode" id="cb39"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb39-1" title="1">$ <span class="fu">diff</span> 1.txt 2.txt -y</a>
<a class="sourceLine" id="cb39-2" title="2"><span class="ex">1</span> 1</a>
<a class="sourceLine" id="cb39-3" title="3"><span class="ex">2</span> 2</a>
<a class="sourceLine" id="cb39-4" title="4"><span class="ex">3</span> <span class="kw">|</span> <span class="ex">7</span></a>
<a class="sourceLine" id="cb39-5" title="5"><span class="ex">4</span> 4</a>
<a class="sourceLine" id="cb39-6" title="6"><span class="ex">5</span> <span class="op"><</span></a>
<a class="sourceLine" id="cb39-7" title="7"><span class="ex">6</span> 6</a>
<a class="sourceLine" id="cb39-8" title="8"><span class="ex">7</span> 7</a>
<a class="sourceLine" id="cb39-9" title="9"> <span class="op">></span> <span class="ex">8</span></a></code></pre></div></section><section id="section-2" class="title-slide slide level2"><h2></h2><div class="sourceCode" id="cb40"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb40-1" title="1">$ <span class="fu">diff</span> 1.txt 2.txt </a>
<a class="sourceLine" id="cb40-2" title="2"><span class="ex">3c3</span> </a>
<a class="sourceLine" id="cb40-3" title="3"><span class="op"><</span> <span class="ex">3</span> </a>
<a class="sourceLine" id="cb40-4" title="4"><span class="ex">---</span></a>
<a class="sourceLine" id="cb40-5" title="5"><span class="op">></span> <span class="ex">7</span> </a>
<a class="sourceLine" id="cb40-6" title="6"><span class="ex">5d4</span> </a>
<a class="sourceLine" id="cb40-7" title="7"><span class="op"><</span> <span class="ex">5</span> </a>
<a class="sourceLine" id="cb40-8" title="8"><span class="ex">7a7</span> </a>
<a class="sourceLine" id="cb40-9" title="9"><span class="op">></span> <span class="ex">8</span> </a></code></pre></div>
<ul>
<li>3c3: 1.txt的第3行 change 为2.txt的第3行</li>
<li>< 3 / > 7: change 方式为 1.txt 删除字符3, 2.txt 增加字符7</li>
<li>5d4: 1.txt的第5行 delete</li>
<li>……</li>
</ul></section><section id="section-3" class="title-slide slide level2"><h2></h2><div class="sourceCode" id="cb41"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb41-1" title="1">$ <span class="fu">diff</span> 1.txt 2.txt -c</a>
<a class="sourceLine" id="cb41-2" title="2"><span class="ex">***</span> 1.txt 2016-07-16 19:20:03.593327527 +0800</a>
<a class="sourceLine" id="cb41-3" title="3"><span class="ex">---</span> 2.txt 2016-07-16 19:20:38.829329212 +0800</a>
<a class="sourceLine" id="cb41-4" title="4"><span class="ex">***************</span></a>
<a class="sourceLine" id="cb41-5" title="5"><span class="ex">***</span> 1,7 ****</a>
<a class="sourceLine" id="cb41-6" title="6"> <span class="ex">1</span></a>
<a class="sourceLine" id="cb41-7" title="7"> <span class="ex">2</span></a>
<a class="sourceLine" id="cb41-8" title="8">! <span class="ex">3</span></a>
<a class="sourceLine" id="cb41-9" title="9"> <span class="ex">4</span></a>
<a class="sourceLine" id="cb41-10" title="10"><span class="ex">-</span> 5</a>
<a class="sourceLine" id="cb41-11" title="11"> <span class="ex">6</span></a>
<a class="sourceLine" id="cb41-12" title="12"> <span class="ex">7</span></a>
<a class="sourceLine" id="cb41-13" title="13"><span class="ex">---</span> 1,7 ----</a>
<a class="sourceLine" id="cb41-14" title="14"> <span class="ex">1</span></a>
<a class="sourceLine" id="cb41-15" title="15"> <span class="ex">2</span></a>
<a class="sourceLine" id="cb41-16" title="16">! <span class="ex">7</span></a>
<a class="sourceLine" id="cb41-17" title="17"> <span class="ex">4</span></a>
<a class="sourceLine" id="cb41-18" title="18"> <span class="ex">6</span></a>
<a class="sourceLine" id="cb41-19" title="19"> <span class="ex">7</span></a>
<a class="sourceLine" id="cb41-20" title="20"><span class="ex">+</span> 8</a></code></pre></div>
<ul>
<li>"***"表示变动前的文件</li>
<li>“—”表示变动后的文件</li>
</ul></section><section id="section-4" class="title-slide slide level2"><h2></h2><div class="sourceCode" id="cb42"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb42-1" title="1">$ <span class="fu">diff</span> 1.txt 2.txt -u</a>
<a class="sourceLine" id="cb42-2" title="2"><span class="ex">---</span> 1.txt 2016-07-16 19:20:03.593327527 +0800</a>
<a class="sourceLine" id="cb42-3" title="3"><span class="ex">+++</span> 2.txt 2016-07-16 19:20:38.829329212 +0800</a>
<a class="sourceLine" id="cb42-4" title="4"><span class="ex">@@</span> -1,7 +1,7 @@</a>
<a class="sourceLine" id="cb42-5" title="5"> <span class="ex">1</span></a>
<a class="sourceLine" id="cb42-6" title="6"> <span class="ex">2</span></a>
<a class="sourceLine" id="cb42-7" title="7"><span class="ex">-3</span></a>
<a class="sourceLine" id="cb42-8" title="8"><span class="ex">+7</span></a>
<a class="sourceLine" id="cb42-9" title="9"> <span class="ex">4</span></a>
<a class="sourceLine" id="cb42-10" title="10"><span class="ex">-5</span></a>
<a class="sourceLine" id="cb42-11" title="11"> <span class="ex">6</span></a>
<a class="sourceLine" id="cb42-12" title="12"> <span class="ex">7</span></a>
<a class="sourceLine" id="cb42-13" title="13"><span class="ex">+8</span></a></code></pre></div>
<ul>
<li>“—”表示变动前的文件</li>
<li>“+++”表示变动后的文件</li>
</ul></section><section id="practice-5" class="title-slide slide level2"><h2>Practice</h2><blockquote>
<p>diff 2.txt 1.txt -u</p>
</blockquote>
<div class="fragment">
<div class="sourceCode" id="cb43"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb43-1" title="1">$ <span class="fu">diff</span> 2.txt 1.txt -u</a>
<a class="sourceLine" id="cb43-2" title="2"><span class="ex">---</span> 2.txt 2016-07-16 19:20:38.829329212 +0800</a>
<a class="sourceLine" id="cb43-3" title="3"><span class="ex">+++</span> 1.txt 2016-07-16 19:20:03.593327527 +0800</a>
<a class="sourceLine" id="cb43-4" title="4"><span class="ex">@@</span> -1,7 +1,7 @@</a>
<a class="sourceLine" id="cb43-5" title="5"> <span class="ex">1</span></a>
<a class="sourceLine" id="cb43-6" title="6"> <span class="ex">2</span></a>
<a class="sourceLine" id="cb43-7" title="7"><span class="ex">-7</span></a>
<a class="sourceLine" id="cb43-8" title="8"><span class="ex">+3</span></a>
<a class="sourceLine" id="cb43-9" title="9"> <span class="ex">4</span></a>
<a class="sourceLine" id="cb43-10" title="10"><span class="ex">+5</span></a>
<a class="sourceLine" id="cb43-11" title="11"> <span class="ex">6</span></a>
<a class="sourceLine" id="cb43-12" title="12"> <span class="ex">7</span></a>
<a class="sourceLine" id="cb43-13" title="13"><span class="ex">-8</span></a></code></pre></div>
</div></section><section id="practice-6" class="title-slide slide level2"><h2>Practice</h2><blockquote>
<p>git diff 使用的是哪种 diff 形式?</p>
</blockquote></section><section id="git-diff-与-git-log" class="title-slide slide level2"><h2>git diff 与 git log</h2><ul>
<li>git diff 不关心待比较文件的历史,也不关心分支,只关注当前对象本身</li>
<li>git log 更关注文件的来龙去脉,即对象的parent、son……</li>
</ul></section><section id="practice-7" class="title-slide slide level2"><h2>Practice</h2><blockquote>
<p>比较当前HEAD版本和上一个HEAD版本</p>
</blockquote>
<div class="fragment">
<div class="sourceCode" id="cb44"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb44-1" title="1">$ <span class="fu">git</span> diff HEAD^ HEAD</a></code></pre></div>
</div></section><section id="practice-8" class="title-slide slide level2"><h2>Practice</h2><blockquote>
<p>比较3者的异同:<br />
1. $ git diff topic master<br />
2. $ git diff topic..master<br />
3. $ git diff topic…master</p>
</blockquote>
<div class="fragment">
<ol type="1">
<li>Changes between the tips of the topic and the master branches.</li>
<li>Same as above.</li>
<li>Changes that occurred on the master branch since when the topic branch was started off it.</li>
</ol>
</div></section><section id="git-difftool" class="title-slide slide level2"><h2>git difftool</h2><p><img src="img/git-difftool-merge.png" width="80%" /></p>
<div class="foottext">
设置方法请search,或查看《Git聊天入门》
</div></section></section>
<section><section id="git-branch" class="title-slide slide level1"><h1>git branch</h1></section><section id="focal-point-2" class="title-slide slide level2"><h2>Focal Point</h2><table>
<tbody>
<tr class="odd">
<td>git branch</td>
<td>查看所有分支</td>
</tr>
<tr class="even">
<td>git branch -v</td>
<td>查看所有分支,和当前最新的commit</td>
</tr>
<tr class="odd">
<td>git branch -vv</td>
<td>查看所有分支,和当前最新的commit<br>和upstream</td>
</tr>
<tr class="even">
<td>git branch xyz</td>
<td>创建 xyz 分支</td>
</tr>
<tr class="odd">
<td>git branch -d xyz</td>
<td>删除 xyz 分支,如果分支尚未合入主干<br>或upstream,则失败</td>
</tr>
<tr class="even">
<td>git branch -D xyz</td>
<td>删除 xyz 分支,强制</td>
</tr>
<tr class="odd">
<td></td>
<td></td>
</tr>
</tbody>
</table></section><section id="branch-is-ref" class="title-slide slide level2"><h2>branch is ref</h2><div class="sourceCode" id="cb45"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb45-1" title="1"><span class="ex">GitChat.git</span>$ tree .git/refs</a>
<a class="sourceLine" id="cb45-2" title="2"><span class="ex">.git/refs</span></a>
<a class="sourceLine" id="cb45-3" title="3">├── <span class="ex">heads</span></a>
<a class="sourceLine" id="cb45-4" title="4">│ ├── <span class="ex">master</span></a>
<a class="sourceLine" id="cb45-5" title="5">│ └── <span class="ex">zte</span></a>
<a class="sourceLine" id="cb45-6" title="6">├── <span class="ex">remotes</span></a>
<a class="sourceLine" id="cb45-7" title="7">│ ├── <span class="ex">origin</span></a>
<a class="sourceLine" id="cb45-8" title="8">│ │ ├── <span class="ex">HEAD</span></a>
<a class="sourceLine" id="cb45-9" title="9">│ │ └── <span class="ex">master</span></a>
<a class="sourceLine" id="cb45-10" title="10">│ └── <span class="ex">zte</span></a>
<a class="sourceLine" id="cb45-11" title="11">│ ├── <span class="ex">master</span></a>
<a class="sourceLine" id="cb45-12" title="12">│ └── <span class="ex">zte</span></a>
<a class="sourceLine" id="cb45-13" title="13">└── <span class="ex">tags</span></a>
<a class="sourceLine" id="cb45-14" title="14"></a>
<a class="sourceLine" id="cb45-15" title="15"><span class="ex">5</span> directories, 6 files</a></code></pre></div>
<ul>
<li>tag 可以理解为仅是指针</li>
<li>branch 不仅仅是指针,还包括向前追溯的一串节点信息</li>
</ul></section><section id="practice-9" class="title-slide slide level2"><h2>Practice</h2><blockquote>
<p>查看某 branch 内commit的关系</p>
</blockquote>
<div class="fragment">
<div class="sourceCode" id="cb46"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb46-1" title="1"><span class="ex">GitChat.git</span>$ git log --oneline --graph</a>
<a class="sourceLine" id="cb46-2" title="2"><span class="ex">*</span> 384453f 开始写《Git基础》的Slides</a>
<a class="sourceLine" id="cb46-3" title="3"><span class="ex">*</span> 04e9afe 增加Slides功能</a>
<a class="sourceLine" id="cb46-4" title="4"><span class="ex">*</span> ade6a93 新增章节:push 错了,我要丢弃remote上的某个节点</a>
<a class="sourceLine" id="cb46-5" title="5"><span class="ex">*</span> 145fedb 增加章节:分支名能否用中文</a>
<a class="sourceLine" id="cb46-6" title="6"><span class="ex">*</span> 9bdce19 笔误</a>
<a class="sourceLine" id="cb46-7" title="7"><span class="ex">*</span> 5136879 WWDC2016中刚刚宣布OS.X更名为macOS,本文即刻修改</a>
<a class="sourceLine" id="cb46-8" title="8"><span class="ex">*</span> b748256 增加章节:如何避免arc diff玷污现有节点; 如何创建只包含部分文件的评审单</a>
<a class="sourceLine" id="cb46-9" title="9"><span class="ex">*</span> d6efce6 增加章节: arc diff的ubuntu安装</a>
<a class="sourceLine" id="cb46-10" title="10"><span class="ex">*</span> f8c101d Merge remote-tracking branch <span class="st">'zte/master'</span></a>
<a class="sourceLine" id="cb46-11" title="11"><span class="kw">|</span><span class="ex">\ </span> </a>
<a class="sourceLine" id="cb46-12" title="12"><span class="kw">|</span> <span class="ex">*</span> 1631166 增加:整理git的外网托管网站</a>
<a class="sourceLine" id="cb46-13" title="13"><span class="kw">|</span> <span class="ex">*</span> 5d200a3 新增:分支的合并(git merge)有哪几种场景,合并时如何处理分支中的“垃圾”log</a>
<a class="sourceLine" id="cb46-14" title="14"><span class="kw">|</span> <span class="ex">*</span> 11f41a5 完善 git proxy 的描述</a>
<a class="sourceLine" id="cb46-15" title="15"><span class="ex">*</span> <span class="kw">|</span> <span class="ex">9238c69</span> 新增 Round8:git与phabricator</a>
<a class="sourceLine" id="cb46-16" title="16"><span class="kw">|</span><span class="ex">/</span> </a>
<a class="sourceLine" id="cb46-17" title="17"><span class="ex">*</span> 9d8d843 使用 rawgit.com 展示</a></code></pre></div>
</div></section><section id="practice-10" class="title-slide slide level2"><h2>Practice</h2><blockquote>
<p>查看所有 branch 的commit的关系</p>
</blockquote>
<div class="fragment">
<div class="sourceCode" id="cb47"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb47-1" title="1"><span class="ex">GitChat.git</span>$ git log --oneline --graph --all</a>
<a class="sourceLine" id="cb47-2" title="2"><span class="ex">*</span> 5e0725b Merge branch <span class="st">'master'</span> into zte</a>
<a class="sourceLine" id="cb47-3" title="3"><span class="kw">|</span><span class="ex">\ </span> </a>
<a class="sourceLine" id="cb47-4" title="4"><span class="kw">|</span> <span class="ex">*</span> 384453f 开始写《Git基础》的Slides</a>
<a class="sourceLine" id="cb47-5" title="5"><span class="kw">|</span> <span class="ex">*</span> 04e9afe 增加Slides功能</a>
<a class="sourceLine" id="cb47-6" title="6"><span class="ex">*</span> <span class="kw">|</span> <span class="ex">21376f0</span> Merge branch <span class="st">'master'</span> into zte</a>
<a class="sourceLine" id="cb47-7" title="7"><span class="kw">|</span><span class="ex">\ \ </span> </a>
<a class="sourceLine" id="cb47-8" title="8"><span class="kw">|</span> <span class="kw">|</span><span class="ex">/</span> </a>
<a class="sourceLine" id="cb47-9" title="9"><span class="kw">|</span> <span class="ex">*</span> ade6a93 新增章节:push 错了,我要丢弃remote上的某个节点</a>
<a class="sourceLine" id="cb47-10" title="10"><span class="ex">*</span> <span class="kw">|</span> <span class="ex">f7d4f08</span> Merge branch <span class="st">'master'</span> into zte</a>
<a class="sourceLine" id="cb47-11" title="11"><span class="kw">|</span><span class="ex">\ \ </span> </a>
<a class="sourceLine" id="cb47-12" title="12"><span class="kw">|</span> <span class="kw">|</span><span class="ex">/</span> </a>
<a class="sourceLine" id="cb47-13" title="13"><span class="kw">|</span> <span class="ex">*</span> 145fedb 增加章节:分支名能否用中文</a>
<a class="sourceLine" id="cb47-14" title="14"><span class="ex">*</span> <span class="kw">|</span> <span class="ex">e668a52</span> 增加一点zte公司内部的解释</a>
<a class="sourceLine" id="cb47-15" title="15"><span class="kw">|</span><span class="ex">/</span> </a>
<a class="sourceLine" id="cb47-16" title="16"><span class="ex">*</span> 9bdce19 笔误</a>
<a class="sourceLine" id="cb47-17" title="17"><span class="ex">*</span> 5136879 WWDC2016中刚刚宣布OS.X更名为macOS,本文即刻修改</a>
<a class="sourceLine" id="cb47-18" title="18"><span class="ex">*</span> b748256 增加章节:如何避免arc diff玷污现有节点; 如何创</a>
<a class="sourceLine" id="cb47-19" title="19"><span class="ex">*</span> d6efce6 增加章节: arc diff的ubuntu安装</a></code></pre></div>
</div></section><section id="practice-11" class="title-slide slide level2"><h2>Practice</h2><blockquote>
<p>查看某个 commit 所属的 branch</p>
</blockquote>
<div class="fragment">
<div class="sourceCode" id="cb48"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb48-1" title="1"><span class="ex">GitChat.git</span>$ git branch --contains 9d8d</a>
<a class="sourceLine" id="cb48-2" title="2"><span class="ex">*</span> master</a>
<a class="sourceLine" id="cb48-3" title="3"> <span class="ex">zte</span></a></code></pre></div>
</div></section></section>
<section><section id="git-checkout" class="title-slide slide level1"><h1>git checkout</h1></section><section id="原理图-1" class="title-slide slide level2"><h2>原理图</h2><embed src="img/git-checkout.svg" type="image/svg+xml" style="background-color:white" /></section></section>
<section><section id="git-fetchpullpush" class="title-slide slide level1"><h1>git fetch/pull/push</h1></section><section id="原理图-2" class="title-slide slide level2"><h2>原理图</h2><embed src="img/git-remote.svg" type="image/svg+xml" style="background-color:white" /></section></section>
<section><section id="git-merge" class="title-slide slide level1"><h1>git merge</h1></section><section id="focal-point-3" class="title-slide slide level2"><h2>Focal Point</h2><ul>
<li>不必从干净的工作目录开始合并</li>
<li>但劝你最好从干净的工作目录开始合并,除非你想把自己搞晕</li>
<li>merge 前做好解决冲突的心理准备</li>
<li>merge 前看清楚当前所处的 branch</li>
</ul></section><section id="合并冲突" class="title-slide slide level2"><h2>合并冲突</h2><p>步骤:</p>
<ol type="1">
<li>git merge rev //糟糕,冲突了</li>
<li>git diff //看看啥冲突,此时的 git diff 和平常的稍有不同</li>
<li>vi conflictFile 或 git mergetool //解决冲突,最后记得删掉各种标记符号</li>
<li>git add //重新add</li>
<li>git commit //里面会有 merge 的提示</li>
</ol></section><section id="practice-12" class="title-slide slide level2"><h2>Practice</h2><blockquote>
<p>演示合并冲突、及解决</p>
</blockquote></section><section id="合并策略" class="title-slide slide level2"><h2>合并策略</h2><ul>
<li>退化合并
<ul>
<li>already up-to-date</li>
<li>fast-forward</li>
</ul></li>
<li>常规合并
<ul>
<li>resolve :两分支合并</li>
<li>recursive :两分支,但多个合并基础的合并</li>
<li>octopus :多分支合并</li>
</ul></li>
<li>特殊合并
<ul>
<li>ours</li>
<li>subtree</li>
</ul></li>
</ul>
<div class="foottext">
<br><br>完整的策略列表: git help merge – 搜索 <strong>MERGE STRATEGIES</strong>
</div></section><section id="合并策略的选择" class="title-slide slide level2"><h2>合并策略的选择</h2><ul>
<li>git会根据用户的merge命令参数自动决定使用哪种策略</li>
<li>用户也可以 -s strategy 指定策略 —— <strong>慎重</strong>
<ul>
<li>git merge -s resolve …</li>
<li>git merge -s ours …</li>
<li>git merge -s subtree …</li>
<li>git merge –no-ff</li>
</ul></li>
</ul></section></section>
<section><section id="git-进阶" class="title-slide slide level1" data-background-color="#3962c3"><h1>Git 进阶</h1></section><section id="wkevins-cheatsheet" class="title-slide slide level2"><h2>wkevin’s cheatsheet</h2><p><img data-src="img/git-common-cmd.png" /></p></section></section>
<section id="git-remote" class="title-slide slide level1"><h1>git remote</h1></section>
<section><section id="git-reset" class="title-slide slide level1"><h1>git reset</h1></section><section id="原理图-3" class="title-slide slide level2"><h2>原理图</h2><embed src="img/git-reset.svg" type="image/svg+xml" style="background-color:white" /></section></section>
<section id="git-rebase" class="title-slide slide level1"><h1>git rebase</h1></section>
<section id="git-object" class="title-slide slide level1"><h1>Git Object</h1></section>
<section id="git-生态" class="title-slide slide level1" data-background-color="#3962c3"><h1>Git 生态</h1></section>
<section><section id="git-托管平台" class="title-slide slide level1"><h1>Git 托管平台</h1></section><section id="github-vs-gitlab" class="title-slide slide level2"><h2><a href="https://about.gitlab.com/devops-tools/github-vs-gitlab.html">Github Vs Gitlab</a></h2><p><img data-src="img/github.vs.gitlab.png" /></p></section><section id="托管平台扩展的scm" class="title-slide slide level2"><h2>托管平台扩展的SCM</h2><p>fork、PR</p></section><section id="基于托管平台的ci" class="title-slide slide level2"><h2>基于托管平台的CI</h2><p><img data-src="img/gitlab.ci.png" /></p></section><section id="github-actions" class="slide level3">
<h3><a href="https://github.com/features/actions">Github Actions</a></h3>
<div class="sourceCode" id="cb49"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb49-1" title="1"><span class="kw">|</span><span class="ex">--</span> hello-world (repository)</a>
<a class="sourceLine" id="cb49-2" title="2"><span class="kw">|</span> <span class="kw">|</span><span class="ex">__</span> .github</a>
<a class="sourceLine" id="cb49-3" title="3"><span class="kw">|</span> <span class="kw">|</span><span class="ex">__</span> main.workflow</a>
<a class="sourceLine" id="cb49-4" title="4"><span class="kw">|</span> <span class="kw">|</span><span class="ex">__</span> action-a</a>
<a class="sourceLine" id="cb49-5" title="5"><span class="kw">|</span> │<span class="ex">__</span> Dockerfile</a>
<a class="sourceLine" id="cb49-6" title="6"><span class="kw">|</span> │<span class="ex">__</span> README.md</a>
<a class="sourceLine" id="cb49-7" title="7"><span class="kw">|</span> <span class="kw">|</span><span class="ex">__</span> entrypoint.sh </a>
<a class="sourceLine" id="cb49-8" title="8"><span class="kw">|</span></a></code></pre></div>
<p><br><br />
<a href="https://developer.github.com/actions/creating-github-actions/creating-a-new-action/">Creating a new GitHub Action</a></p>
</section><section id="gitlab-ci-gitlab-runner" class="slide level3">
<h3>Gitlab CI & <a href="https://docs.gitlab.com/runner/">Gitlab Runner</a></h3>
<ul>
<li>Multi-platform</li>
<li>Multi-language</li>
<li>Stable</li>
<li>Parallel builds</li>
<li>Realtime logging</li>
<li>Flexible pipelines</li>
<li>Versioned pipelines</li>
<li>Autoscaling</li>
<li>Build artifacts</li>
<li>Docker support</li>
<li>Container Registry</li>
<li>Protected variables</li>
<li>Environments</li>
</ul>
</section></section>
<section><section id="git-workflow" class="title-slide slide level1"><h1>Git Workflow</h1></section><section id="工作流是一种约定" class="title-slide slide level2"><h2>工作流是一种约定</h2><ul>
<li>工作流是软件团队成员之间的约定</li>
<li>约定内容包括:
<ul>
<li>对分支的定义</li>
<li>对合并触发时机的定义</li>
<li>对repo的分布、fork的定义</li>
<li>repo的人员分工的定义</li>
<li>对权限的约定:
<ul>
<li>git的分布式特性让“一个领导或管理员统管权限”变得无法操作</li>
<li>可以适当运用gitlab等软件来约束权限,但它并不能解决所有问题</li>
</ul></li>
</ul></li>
</ul></section><section id="工作流因团队而异" class="title-slide slide level2"><h2>工作流因团队而异</h2><ul>
<li>不同的团队需要根据人员(能力、规模)、时间、发布策略等制定不同的工作流
<ul>
<li>单机工作流</li>
<li>小团队工作流</li>
<li>分布式工作流</li>