-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
1113 lines (966 loc) · 43.7 KB
/
index.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="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Git</title>
<meta name="description" content="A completely childish person with no manners">
<meta name="author" content="Alexander Groß">
<link href="data:image/x-icon;base64,AAABAAEAEBAAAAAAAABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAxTO0AMUztADFN7gAxTe4AMU3uADFN7wAxTe8AMk3w/zJN8P8yTvEAMk7xADJO8gAyTvIAMk7zAP///wD///8AMUztADFN7gAxTe4AMU3uADFN7wAxTe8AMk3w/zJN8P8yTvH/Mk7x/zJO8gAyTvIAMk7zADJO8wD///8A////ADFN7gAxTe4AMU3uADFN7wAxTe8AMk3w/zJN8P8yTvH/Mk7x/zJO8v8yTvL/Mk7zADJO8wAyT/QA////AP///wAxTe4AMU3uADFN7wAxTe8AMk3w/zJN8P8yTvH/Mk7x9TJO8vYyTvL/Mk7z/zJO8/8yT/QAM0/1AP///wD///8AMU3uADFN7wAxTe8AMk3w/zJN8P8yTvH/Mk7x/zJO8gAyTvIAMk7z/zJO8/8yT/T/M0/1/zNP9QD///8A////ADFN7wAxTe8AMk3w/zJN8P8yTvH/Mk7x/zJO8v8yTvIAMk7zADJO8/8yT/T/M0/1/zNP9f8zT/b/////AP///wAxTe8AMk3w/zJN8P8yTvH/Mk7x/zJO8v8yTvL/Mk7zNzJO8zcyT/T/M0/1/zNP9f8zT/b/M0/2/zNQ9/////8AMk3w/zJN8P8yTvH/Mk7x/zJO8v8yTvL/Mk7z/zJO8zcyT/Q3M0/1/zNP9QAzT/YAM0/29jNQ9/8zUPf/M1D4/zJN8P8yTvH/Mk7x/zJO8v8yTvL/Mk7z/zJO8/8yT/Q3M0/1NzNP9f8zT/YAM0/2ADNQ9/UzUPf/M1D4/zNQ+f8yTvEAMk7x/zJO8v8yTvL/Mk7z/zJO8/8yT/T/M0/1NzNP9TczT/YAM0/2ADNQ9/8zUPf/M1D4/zNQ+f////8AMk7xADJO8gAyTvL/Mk7z/zJO8/8yT/T/M0/1/zNP9QAzT/YAM0/2ADNQ9/8zUPj/M1D4/zNQ+f////8A////ADJO8gAyTvIAMk7zADJO8/8yT/T/M0/1/zNP9f8zT/YAM0/2ADNQ9/8zUPj/M1D4/zNQ+f8zUPkA////AP///wAyTvIAMk7zADJO8wAyT/QAM0/1/zNP9f8zT/YAM0/2aDNQ9/QzUPf/M1D4/zNQ+f8zUPkANFD6AP///wD///8AMk7zADJO8wAyT/QAM0/1ADNP9QAzT/YAM0/2OjNQ9/8zUPf/M1D4/zNQ+f8zUPkANFD6ADRR+gD///8A////ADJO8wAyT/QAM0/1ADNP9QAzT/YAM0/2ADNQ9/8zUPf/M1D4/zNQ+f8zUPkANFD6ADRR+gA0UfoA////AP///wAyT/QAM0/1ADNP9QAzT/YAM0/2ADNQ9wAzUPgAM1D4/zNQ+f8zUPkANFD6ADRR+gA0UfoANFH7AP///wD///8A/n8AAPw/AAD4HwAA8A8AAOGHAADBgwAAgYEAAAGwAAABsAAAgeEAAMHDAADhhwAA8w8AAP4fAAD8PwAA/n8AAA==" rel="icon" type="image/x-icon" />
<link rel="stylesheet" href="css/reset.css">
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/theme/simplest.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 ) ? 'css/print/pdf.css' : 'css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
</head>
<body>
<div class="reveal">
<div class="slides">
<section>
<div class="cross-fade fade-4">
<img src="images/git-logo.svg"
alt="Git logo"
style="width: 60%">
<img src="//imgs.xkcd.com/comics/git.png"
alt="xkcd">
<a href="https://twitter.com/mikehostetler/status/784101927260917760?s=09"
target="_blank"
style="display: block;">
<img src="images/search-volume.png" alt="Git search volume">
</a>
<a href="https://www.reddit.com/r/ProgrammerHumor/comments/g8rz5s/the_total_miss/"
target="_blank"
style="display: block;">
<img src="https://i.redd.it/qd0ht1mqv9v41.jpg"
alt="A person trying to put a fire out with gasoline">
</a>
</div>
<h3>Commit often, perfect later, publish once</h3>
</section>
<section data-background="#2b2b2b">
<img src="images/subversion-logo.svg"
alt="Subversion logo">
</section>
<section data-background="#2b2b2b">
<img src="images/centralized-vcs.svg"
alt="Centralized VCS">
</section>
<section style="margin-top: -50px;"
data-transition="linear">
<img src="images/distributed-vcs.svg"
alt="Distributed VCS"
style="max-width: 70%">
</section>
<section>
<section data-background="images/futurama-fry.jpg">
</section>
<section>
<h1>Why git?</h1>
<ul>
<li>Everything is <strong>local</strong></li>
<li><strong>Fast</strong>, works offline</li>
<li>Based on <strong>simple rules</strong></li>
<li>Branching and merging is rather <strong>easy</strong></li>
<li>Very <strong>flexible</strong> regarding workflows</li>
<li><strong>Corrections</strong> are possible</li>
<li>Good <strong><a href="https://git-scm.com/docs" target="_blank">documentation</a></strong>, lots of articles and <a href="https://stackoverflow.com/questions/tagged/git" target="_blank">Q&A</a> online</li>
<li>Available on <strong>all platforms</strong></li>
</ul>
</section>
</section>
<section>
<section>
<h1>Hello, git</h1>
<blockquote>
A completely ignorant, childish person with no manners.
<footer>
<cite>— <a href="http://www.urbandictionary.com/define.php?term=Git" target="_blank">Urban Dictionary</a></cite>
</footer>
</blockquote>
</section>
<section>
<pre>$ /dont-panic/</pre>
<blockquote class="twitter-tweet"
data-lang="en"
data-dnt="true"
data-align="center">
<p lang="en"
dir="ltr">
note to self, use the bloody command line. It works!
</p>
— Channing Walton (@channingwalton)
<a href="https://twitter.com/channingwalton/status/160485379248627713">January 20, 2012</a>
</blockquote>
</section>
<section>
<pre>$ git <verb></pre>
<pre>$ git help <verb>
$ git <verb> --help</pre>
</section>
<section>
<pre>$ git init
Initialized empty Git repository in /scratch/.git/
$ echo hello, world > hello.txt
$ git add hello.txt
$ git commit --message 'my first commit!'
[master (root-commit) deadbee] my first commit!
1 file changed, 1 insertion(+)
create mode 100644 hello.txt</pre>
</section>
<section>
<pre>$ git show
<span style="color: #BFBF00; user-select: all">commit deadbeef16165bb95a541321a7acf9cef9731c1d</span>
<span style="user-select: all">Author: Alexander Groß <[email protected]>
Date: Sat Feb 6 12:41:24 2010 +0100
my first commit!
</span>
<span style="color: #85b0fc; user-select: all">diff --git a/hello.txt b/hello.txt
new file mode 100644
index 0000000..4b5fa63
--- /dev/null
+++ b/hello.txt</span>
<span style="color: #1FAECD; user-select: all">@@ -0,0 +1 @@</span>
<span style="color: #00CC00; user-select: all">+hello, world</span></pre>
</section>
<section>
<h2>Content Lifecycle</h2>
<img src="images/lifecycle.svg">
</section>
<section>
<h2>Staging Area = Power</h2>
<a href="http://ndpsoftware.com/git-cheatsheet.html"
target="_blank"><img style="padding-left: 2em" src="images/areas.svg"></a>
</section>
<section>
<h2>Take-aways</h2>
<ul>
<li>
Partial operations
<pre class="badge"
data-badge="git < 2.23"
data-badge-on="git >= 2.23">$ git add --patch
$ git <span class="alt-off">reset HEAD</span><span class="alt-on">restore --staged</span> --patch
$ git <span class="alt-off">checkout</span><span class="alt-on">restore</span> --patch</pre>
</li>
<li>
Temporarily ignore changes to tracked files
<pre>$ git update-index --[no-]skip-worktree</pre>
</li>
<li>
List ignored changes
<pre>$ git ls-files -v | grep '^h'</pre>
</li>
</ul>
</section>
</section>
<section>
<section>
<h1>Branching</h1>
</section>
<section>
<h2>Simple history</h2>
<img src="images/branching/1-simple-history.svg">
</section>
<section>
<blockquote>
<p lang="en"
dir="ltr">Here are some better alternative names for the "master" branch in your source code repository:
<br>
<br>- bleeding-edge
<br>- nevergreen
<br>- works-on-my-machine
<br>- happy-merging-XD
<br>- there-be-real-users
<br>- features-come-here-to-die
<br>- (L°O°)L_|_|_</p>
— Markus Tacker 🇳🇴 (@coderbyheart)
<a href="https://twitter.com/coderbyheart/status/970959569781448705?ref_src=twsrc%5Etfw">March 6, 2018</a>
</blockquote>
</section>
<section>
<h2>The <code>HEAD</code> pointer</h2>
<img src="images/branching/2-HEAD.svg">
</section>
<section>
<h2>Creating a branch</h2>
<pre>$ git branch topic [<where>]</pre>
<p>(<code><where></code> defaults to <code>HEAD</code>)</p>
<img src="images/branching/3-create-branch.svg">
</section>
<section>
<h2>Current branch = where <code>HEAD</code> is</h2>
<pre class="badge"
data-badge="git < 2.23"
data-badge-on="git >= 2.23">$ git <span class="alt-off">checkout</span><span class="alt-on">switch</span> topic</pre>
<img src="images/branching/4-switch-branch.svg">
</section>
<section>
<h2>A Shortcut</h2>
<pre style="width: 100%"
class="badge"
data-badge="git < 2.23"
data-badge-on="git >= 2.23">$ git <span class="alt-off">checkout -b</span><span class="alt-on">switch -c</span> <name> [<where>]
==
$ git branch <name> [<where>] && git <span class="alt-off">checkout</span><span class="alt-on">switch</span> <name>
</pre>
</section>
<section>
<h2>Advancing the <code>topic</code> branch</h2>
<pre>$ git commit -am "work on topic"</pre>
<img src="images/branching/5-advance-topic.svg">
</section>
<section>
<h2>Rule #1</h2>
<h3>The only branch that can change is the current branch.</h3>
</section>
<section>
<h2>Back to <code>master</code></h2>
<pre class="badge"
data-badge="git < 2.23"
data-badge-on="git >= 2.23">$ git <span class="alt-off">checkout</span><span class="alt-on">switch</span> master</pre>
<img src="images/branching/6-back-to-master.svg">
</section>
<section>
<h2>Rule #2</h2>
<h3>When
<code>HEAD</code>'s position changes your working copy will be updated.</h3>
<p>Uncommitted changes will be attempted to be preserved.</p>
</section>
<section>
<h2>Advancing the <code>master</code> branch</h2>
<pre>$ git commit -am "work on master"</pre>
<img src="images/branching/7-advance-master.svg">
</section>
<section>
<h2>Detached <code>HEAD</code></h2>
<img style="object-fit: cover; height: 700px; width: 70%"
alt="A detached head of a sculpture"
src="https://upload.wikimedia.org/wikipedia/commons/2/2b/Roman_-_Portrait_of_the_Emperor_Marcus_Aurelius_-_Walters_23215.jpg">
</section>
<section>
<h2>Detached <code>HEAD</code></h2>
<pre class="badge"
data-badge="git < 2.23"
data-badge-on="git >= 2.23">$ git <span class="alt-off">checkout</span><span class="alt-on">switch --detach</span> deadbeef
<span class="alt-off">Note: checking out 'deadbeef'.
You are in 'detached HEAD' state. You can look
around, make experimental changes and commit them…</span><span class="alt-on">HEAD is now at deadbeef</span></pre>
<img src="images/branching/8-detached-HEAD.svg">
<p>You're on no branch when you <code>checkout</code> a SHA, tag or
remote branch.</p>
</section>
<section>
<h2>Restoring unreachable commits</h2>
<pre>$ git reflog
6bbd21d HEAD@{0}: commit (amend): JUG WIP
e7d4298 HEAD@{1}: commit: JUG WIP
71ab831 HEAD@{2}: checkout: moving from gh-pages to jug
71ab831 HEAD@{3}: commit: Support more than one fade
76cd1b0 HEAD@{4}: commit: Tabs -> spaces
$ git fsck --unreachable | grep commit
unreachable commit 60c5758f209c63e5cc2d00f4c8e3ab8fc7037609
unreachable commit 6bc882d6491597250a2baa880e19f0759e1f585b
unreachable commit 74cfdec6a9ba5b3e70c7bd1128fc3347440539b8
unreachable commit b76bb1f752afaaedc1b21d35c75c3acdce3d46e5</pre>
</section>
</section>
<section>
<section>
<h1>Making corrections</h1>
</section>
<section>
<h2>Modifying the last commit</h2>
<pre>$ git commit --amend -m 'C was bad'</pre>
<img src="images/rewriting/amend.svg">
</section>
<section>
<h2>Undoing recent commits</h2>
<pre>$ git reset --hard B
# Like a pro:
$ git reset --hard HEAD~</pre>
<img src="images/rewriting/reset.svg">
</section>
<section>
<h2>Applying a negated commit</h2>
<pre>$ git revert [--no-commit] B</pre>
<img src="images/rewriting/revert.svg">
</section>
<section>
<h2><a href="https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History#_the_nuclear_option_filter_branch" target="_blank">Rewriting the whole graph 💣</a></h2>
<ul style="margin-left: -3em">
<li>
Extracting libraries from projects
<pre>$ git filter-branch --subdirectory-filter src/lib -- --all</pre>
</li>
<li>
Ensuring no internal files are published when a project is open-sourced
<pre>$ git filter-branch --index-filter 'git rm secret.txt' HEAD</pre>
</li>
<li>
Converting Subversion repositories with <code>svn:externals</code> (there be <abbr title="dragons" style="text-decoration: none">🐉</abbr>)
<pre>$ git <a href="https://github.com/agross/dotfiles/blob/840272f962c0377e6a6acd62fa42b4f51f5be8e1/git/bin/git-svn-clone-externals" target="_blank">svn-clone-externals</a> svn://…</pre>
</li>
</ul>
</section>
<section id="rebase">
<h2>Rewriting parts of the graph</h2>
<h3>🔜</h3>
</section>
<section>
<h2 style="margin-left: -100px; margin-right: -100px">I'll tell my story <a href="https://twitter.com/dan_abramov/status/952572767584604160" target="_blank">after I heard yours</a></h2>
<pre class="badge"
data-badge="git < 2.23"
data-badge-on="git >= 2.23">$ git <span class="alt-off">checkout</span><span class="alt-on">switch</span> <span class="highlight">topic</span>
$ git rebase master</pre>
<img src="images/integration/diverged-history-rebase.svg">
<p>Commits <code>C</code>, <code>D</code> and <code>E</code> are copied on top of <code>master</code> as <code>C'</code>, <code>D'</code> and <nobr></nobr><code>E'</code>.</p>
</section>
<section style="margin-top: -70px; padding: 0">
<a href="https://twitter.com/matthewpskelton/status/575713627862339586"
target="_blank">
<img src="https://user-images.githubusercontent.com/464795/115330193-947c3600-a161-11eb-9e2b-888fa04f7e34.png">
</a>
</section>
<section>
<h2>Complex Rebase</h2>
<p>How to get rid of <code>C</code> when rebasing <code>client</code> on <code>master</code>?</p>
<img src="images/branching/rebase-onto-1.svg">
</section>
<section>
<h2>Complex Rebase</h2>
<pre>$ git rebase --onto master server client</pre>
<img src="images/branching/rebase-onto-2.svg">
</section>
<section>
<h2>A Second Variant</h2>
<pre>$ git rebase --onto B server client</pre>
<img src="images/branching/rebase-onto-3.svg"
height="500rem">
</section>
<section style="margin-top: -100px; padding: 0">
<blockquote class="twitter-tweet"
lang="en"
data-dnt="true"
data-align="center">
<p lang="en" dir="ltr">
$ git rebase origin/master <a href="http://t.co/pAHtrPrm84">pic.twitter.com/pAHtrPrm84</a>
</p>
—
Alejandro AR (@kinduff)
<a href="https://twitter.com/kinduff/status/556127056938151936">January 16, 2015</a>
</blockquote>
</section>
<section style="padding: 0">
<blockquote class="twitter-tweet"
lang="en"
data-dnt="true"
data-align="center">
<p lang="en" dir="ltr">
git rebase -i ;) <a href="https://t.co/Qy2k7Q0EQJ">pic.twitter.com/Qy2k7Q0EQJ</a>
</p>
—
nixCraft (@nixcraft)
<a href="https://twitter.com/nixcraft/status/861233192300273664">May 7, 2017</a>
</blockquote>
</section>
<section>
<h2><a href="https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History#_changing_multiple" target="_blank">Preparing for code review</a></h2>
<pre>$ git rebase --interactive A</pre>
<img src="images/rewriting/interactive-rebase.svg">
</section>
</section>
<section>
<section>
<h1>Integration</h1>
<br>
<p>Your options:</p>
<ul>
<li><code><a href="#/merge">git merge</a></code> (<a href="#/merge-ff">2 variants</a>)</li>
<li><code><a href="#/rebase">git rebase</a></code></li>
</ul>
</section>
<section>
<blockquote class="twitter-tweet"
data-lang="en"
data-dnt="true"
data-align="center">
<p lang="en" dir="ltr">
Visualizing a "Git Merge" <a href="https://t.co/RQJ2AV7JRQ">pic.twitter.com/RQJ2AV7JRQ</a>
</p>
—
David Rousset (@davrous)
<a href="https://twitter.com/davrous/status/767013225426620417">August 20, 2016</a>
</blockquote>
</section>
<section>
<h2>Diverged History</h2>
<img src="images/integration/diverged-history.svg">
</section>
<section id="merge">
<h2>Recursive Merge</h2>
<pre class="badge"
data-badge="git < 2.23"
data-badge-on="git >= 2.23">$ git <span class="alt-off">checkout</span><span class="alt-on">switch</span> <span class="highlight">master</span>
$ git merge topic</pre>
<img src="images/integration/diverged-history-merge.svg"
height="400rem">
<p><strong>Recursive merge (~ <a href="https://github.blog/2021-08-16-highlights-from-git-2-33/#merge-ort-a-new-merge-strategy" target="_blank">ORT merge</a> since git 2.34):</strong> Integrates two diverged branches.</p>
</section>
<section>
<h2>Undoing The Merge</h2>
<pre>$ git reset --hard <span class="highlight">F</span>
# Like a pro (covers <a href="#/merge">recursive</a> and <a href="#/merge-ff">ff merges</a>):
$ git reset --hard <span class="highlight">@@{1}</span></pre>
<img src="images/integration/diverged-history.svg"
height="420rem">
</section>
<section>
<h2>Linear History</h2>
<img src="images/integration/linear-history.svg">
</section>
<section id="merge-ff">
<h2>Fast-Forward Merge</h2>
<pre class="badge"
data-badge="git < 2.23"
data-badge-on="git >= 2.23">$ git <span class="alt-off">checkout</span><span class="alt-on">switch</span> <span class="highlight">master</span>
$ git merge topic</pre>
<img src="images/integration/linear-history-merge.svg">
<p><strong>Fast-forward merge:</strong> The <code>master</code> pointer can be moved from <code>C</code> to <code>E</code> without losing commits reachable from <code>master</code>.</p>
</section>
<section>
<h2>Controlling <code>git merge</code> behavior</h2>
<pre style="margin-top: 2em">$ git merge --ff-only</pre>
<p>Enforces a <strong>fast-forward merge</strong>, aborts if history is diverged.</p>
<pre style="margin-top: 2em">$ git merge --no-ff</pre>
<p>Enforces a <strong>recursive merge</strong>, even if a fast-forward merge would be possible.</p>
</section>
<section>
<h2>Controlling <code>git merge</code> <a href="https://git-scm.com/docs/git-merge#_merge_strategies"
target="_blank">recursive strategy</a></h2>
<pre style="margin-top: 2em">$ git merge --strategy-option ours</pre>
<p>Prefer <strong>our changes</strong> when encountering conflicts.</p>
<pre style="margin-top: 2em">$ git merge -X theirs</pre>
<p>Prefer <strong>their changes</strong> when encountering conflicts.</p>
</section>
<section>
<h2>Squash merge 🍋</h2>
<pre>$ git merge --squash [--commit] topic</pre>
<img style="width: 75%" src="images/integration/squash-merge.svg">
<p>Merge <code>HEAD</code>'s and <code>topic</code>'s snapshot, create a new commit, but only assign <code>HEAD</code> as its parent.</p>
</section>
<section>
<h2>Octopus merge 🐙</h2>
<pre>$ git merge perf css report</pre>
<img style="width: 60%" src="images/integration/octopus-merge.svg">
<p>Integrate any number of non-conflicting branches with a single merge commit.</p>
</section>
<section>
<h2>Cherry-pick 🍒</h2>
<pre>$ git cherry-pick [--no-commit] D</pre>
<img src="images/integration/cherry-pick.svg">
<p>Apply a commit from somewhere else.</p>
</section>
<section>
<h2>More options</h2>
<ul>
<li>
Make <code>obsolete</code>'s commits reachable, but keep tree as-is
<br>(i.e. archive <code>obsolete</code>)
<pre>$ git merge --strategy=ours obsolete</pre>
</li>
<li>
Craft merge commit with <code>release</code>'s tree
<br>(i.e. no file-based merging)
<pre>$ git commit-tree release^{tree}
-m "Merge branch 'release'"
-p HEAD
-p release</pre>
</li>
</ul>
</section>
</section>
<section>
<section>
<h1>Branching Strategies</h1>
</section>
<section>
<h2>Branches Provide Isolation</h2>
<img src="images/branching-strategies/feature-branches.svg">
<ul>
<li><code><a href="#/merge">git merge</a></code> if you want to keep information about integrated branches</li>
<li><code><a href="#/rebase">git rebase</a></code> if you do not care</li>
</ul>
</section>
<section>
<h2><a href="https://www.endoflineblog.com/oneflow-a-git-branching-model-and-workflow"
target="_blank">OneFlow</a> – Features</h2>
<img src="https://www.endoflineblog.com/img/oneflow/feature-branch-rebase-and-merge-final.png">
</section>
<section>
<h2><a href="https://www.endoflineblog.com/oneflow-a-git-branching-model-and-workflow"
target="_blank">OneFlow</a> – Releases</h2>
<img src="https://www.endoflineblog.com/img/oneflow/release-branch-merge-final.png">
</section>
<section>
<h2><a href="https://www.endoflineblog.com/oneflow-a-git-branching-model-and-workflow"
target="_blank">OneFlow</a> – Hotfixes</h2>
<img src="https://www.endoflineblog.com/img/oneflow/hotfix-branch-merge-final.png">
</section>
<section>
<h2><a href="http://nvie.com/posts/a-successful-git-branching-model/"
target="_blank">git-flow</a></h2>
<a href="images/branching-strategies/gitflow.png"
target="_blank"><img src="images/branching-strategies/gitflow.png"></a>
</section>
<section>
<h2><a href="http://datasift.github.io/gitflow/"
target="_blank">HubFlow</a></h2>
<a href="images/branching-strategies/hubflow.png"
target="_blank"><img src="images/branching-strategies/hubflow.png"></a>
</section>
<section>
<h2><a href="https://www.gerritcodereview.com/"
target="_blank">Gerrit</a></h2>
<img src="https://gitenterprise.files.wordpress.com/2013/02/gitgerrit-webinar-lm-20130126-series-2-final-workflow.png">
</section>
</section>
<section>
<section>
<h1>Workflows</h1>
</section>
<section>
<a href="https://twitter.com/lxztlr/status/986677050248519681"
target="_blank">
<pre style="margin-top: -3em">$ git config --global alias.pfusch 'push -f'</pre>
</a>
<blockquote class="twitter-tweet"
lang="en"
data-dnt="true"
data-align="center">
<p lang="en" dir="ltr">
May the 4th be with you 😁
<a href="https://t.co/TnOUaGeoyU">pic.twitter.com/TnOUaGeoyU</a>
</p>
— Jen Gentleman 🌺 (@JenMsft)
<a href="https://twitter.com/JenMsft/status/992380382736601090?ref_src=twsrc%5Etfw">May 4, 2018</a>
</blockquote>
</section>
<section>
<h2>Centralized</h2>
<img src="images/workflow/centralized.svg"
alt="Centralized workflow">
</section>
<section>
<h2>Integration Manager</h2>
<img src="images/workflow/integration-manager.svg"
alt="Integration manager">
</section>
<section>
<h2>Benevolent Dictator</h2>
<img src="images/workflow/benevolent-dictator.svg"
alt="Benevolent dictator">
</section>
<section>
<h2>Ad-hoc</h2>
<p>Server (9418/tcp)</p>
<pre style="width: 115%; margin-left: -10%">$ git daemon --base-path=. --export-all --verbose
[4242] Ready to rumble</pre>
<p>Client</p>
<pre style="width: 115%; margin-left: -10%">$ git clone git://host/relative/path/to/repo/.git foo
Cloning into 'foo'...</pre>
<pre style="width: 115%; margin-left: -10%">$ git remote add <span class="highlight">hans</span> git://host/relative/path/to/repo/.git
$ git fetch <span class="highlight">hans</span>
remote: Counting objects: 42, done.
…
From git://host/relative/path/to/repo/.git
e3205a5..0282413 master -> <span class="highlight">hans</span>/master</pre>
</section>
</section>
<section>
<section>
<h1>Git Internals</h1>
</section>
<section>
<h2>Commit = Trees + Blobs</h2>
<img src="images/internals/commit-objects-hello.svg"
alt="A commit object has references to tree and blob objects">
</section>
<section data-transition="slide-in none">
<h2>Commit = Trees + Blobs</h2>
<img src="images/internals/commit-objects.svg"
alt="A commit object has references to tree and blob objects">
</section>
<section data-transition="none slide-out">
<h2>Commit = Trees + Blobs</h2>
<img src="images/internals/commit-objects-subdir.svg"
alt="A commit object has references to tree and blob objects">
</section>
<section>
<h2>History = Linked Commits</h2>
<img src="images/internals/commit-history.svg"
alt="The history is a sequence of commits objects">
</section>
<section>
<h2>Pointers Everywhere</h2>
<img src="images/internals/branch-and-history.svg"
alt="Pointers reference individual commits">
</section>
<section data-transition="slide-in none">
<h2>Pointers Everywhere</h2>
<img src="images/internals/data-model-1.svg"
alt="Full data model (first commit)">
</section>
<section data-transition="none">
<h2>Pointers Everywhere</h2>
<img src="images/internals/data-model-2.svg"
alt="Full data model (second commit)">
</section>
<section data-transition="none">
<h2>Pointers Everywhere</h2>
<img src="images/internals/data-model-3.svg"
alt="Full data model (third commit)">
</section>
<section>
<h2>Delta Storage</h2>
<img src="images/internals/delta-storage.svg"
alt="Delta storage">
</section>
<section>
<h2>Snapshot Storage</h2>
<img src="images/internals/snapshot-storage.svg"
alt="Snapshot storage">
</section>
</section>
<section>
<section>
<h1>Advanced Topics</h1>
</section>
<section>
<h2>Throw-Away Integration Branches</h2>
<ul>
<li>Use temporary <code>pu</code> branches</li>
<li>Do not base any work off of <code>pu</code></li>
<li>Enable “Reuse recorded resolution”
<pre>git config --global rerere.enabled true
git config --global rerere.autoUpdate true</pre></li>
</ul>
</section>
<section class="image" data-transition="slide-in none">
<pre># All branches were tested in isolation</pre>
<img src="images/pu/pu-1.svg"
alt="Three features are done and work in isolation">
</section>
<section class="image" data-transition="none">
<pre class="badge"
data-badge="git < 2.23"
data-badge-on="git >= 2.23">$ git <span class="alt-off">checkout -b</span><span class="alt-on">switch -c</span> pu master</pre>
<img src="images/pu/pu-2.svg"
alt="Create a temporary branch for proposed updates">
</section>
<section class="image" data-transition="none">
<pre>$ for b in <span class="highlight">perf</span> <span class="highlight">css</span> <span class="highlight">report</span>; do git merge $b; done</pre>
<img src="images/pu/pu-3.svg"
alt="Merge topics and resolve conflicts, test all feature together">
</section>
<section class="image" data-transition="none">
<pre>$ git reset --hard master</pre>
<img src="images/pu/pu-4.svg"
alt="Back to square one">
</section>
<section class="image" data-transition="none">
<pre>$ for b in <span class="highlight">css</span> <span class="highlight">report</span>; do git merge $b; done</pre>
<img src="images/pu/pu-5.svg"
alt="The second integration attempt is successful">
</section>
<section class="image" data-transition="none">
<pre style="letter-spacing: -1.5px"
class="badge offset"
data-badge="git < 2.23"
data-badge-on="git >= 2.23">$ git <span class="alt-off">checkout</span><span class="alt-on">switch</span> master; git merge pu; git branch -d pu</pre>
<img src="images/pu/pu-6.svg"
alt="Merge pu into master">
</section>
<section>
<h2>Bisecting</h2>
<ul>
<li>Attempts to find bug-introducing commits by testing a minimum set of revisions</li>
<li>Enters detached <code>HEAD</code> state while searching</li>
<li>After the bad commit has been found, undo it
<pre>git revert [--no-commit] <bad-commit></pre></li>
<li>Automate testing
<pre>git bisect run <some-script></pre></li>
<li><code>some-script</code> can do things like <code>cherry-pick</code>ing reproductions, <a href="https://github.com/GROSSWEBER/git-bisect-demo">demo available</a></li>
</ul>
</section>
<section class="image" data-transition="slide-in none">
<h3 style="margin-left: -100px; margin-right: -100px"><code>v1.0</code> works but <code>v1.1</code> contains a regression</h3>
<pre>$ git stash push -m "whatever you're doing"</pre>
<img src="images/bisect/bisect-1.svg"
alt="v1.0 works but commits between v1.0 and v1.1 broke something">
</section>
<section class="image" data-transition="none">
<h3>Start looking for the bug</h3>
<pre>$ git bisect start <span class="highlight">v1.1</span> <span class="highlight">v1.0</span></pre>
<img src="images/bisect/bisect-2.svg"
alt="Start searching the breaking commit">
</section>
<section class="image" data-transition="none">
<h3>Test commit <code>D</code></h3>
<pre>$ make test # => error</pre>
<img src="images/bisect/bisect-2.svg"
alt="Test your app at commit D">
</section>
<section class="image" data-transition="none">
<h3>Give feedback about <code>D</code></h3>
<pre>$ git bisect <span class="highlight">bad</span></pre>
<img src="images/bisect/bisect-3.svg"
alt="Give git feedback about the test result">
</section>
<section class="image" data-transition="none">
<h3>Test commit <code>B</code></h3>
<pre>$ make test # => success</pre>
<img src="images/bisect/bisect-3.svg"
alt="Test your app at commit B">
</section>
<section class="image" data-transition="none">
<h3>Give feedback about <code>B</code></h3>
<pre>$ git bisect <span class="highlight">good</span></pre>
<img src="images/bisect/bisect-4.svg"
alt="Give git feedback about the test result">
</section>
<section class="image" data-transition="none">
<h3>Test commit <code>C</code></h3>
<pre>$ make test # => success</pre>
<img src="images/bisect/bisect-4.svg"
alt="Test your app at commit C">
</section>
<section class="image" data-transition="none">
<h3>Give feedback about <code>C</code></h3>
<pre>$ git bisect <span class="highlight">good</span></pre>
<img src="images/bisect/bisect-5.svg"
alt="Give git feedback about the test result">
</section>
<section class="image" data-transition="none">
<h3>Culprit found!</h3>
<pre># D is the first bad revision</pre>
<img src="images/bisect/bisect-5.svg"
alt="git reports first bad revision">
</section>
<section class="image" data-transition="none">
<h3>Exit search</h3>
<pre>$ git bisect reset</pre>
<img src="images/bisect/bisect-1.svg"
alt="After reset the graph looks like before">
</section>
<section class="image" data-transition="slide-in none">
<h3><a href="https://github.com/GROSSWEBER/git-bisect-demo/tree/retrofit" target="_blank"> <code>bisect</code> and <code>cherry-pick</code></a></h3>
<pre class="badge offset"
data-badge="git < 2.23"
data-badge-on="git >= 2.23">$ git <span style="letter-spacing: -1px"><span class="alt-off">checkout -b</span><span class="alt-on">switch -c</span> repro v1.1 && git commit -m 'repro'</span></pre>
<img src="images/bisect/bisect-cherry-pick-1.svg"
alt="Create bug reproduction commit">
</section>
<section class="image" data-transition="none">
<h3>Start looking for the bug</h3>
<pre>$ git bisect start <span class="highlight">v1.1</span> <span class="highlight">v1.0</span></pre>
<img src="images/bisect/bisect-cherry-pick-2.svg"
alt="Create bug reproduction commit">
</section>
<section class="image" data-transition="none">
<h3>Apply <code>repro</code> commit</h3>
<pre>$ git cherry-pick <span class="highlight">repro</span></pre>
<img src="images/bisect/bisect-cherry-pick-3.svg"
alt="Apply reproduction on top of HEAD">
</section>
<section class="image" data-transition="none">
<h3>Test commit <code>D</code> + <code>R'</code></h3>
<pre>$ make test # => error</pre>
<img src="images/bisect/bisect-cherry-pick-3.svg"
alt="Test your app at commit D with R'">
</section>
<section class="image" data-transition="none">
<h3>Undo <code>R'</code></h3>
<pre>$ git reset --hard HEAD~</pre>
<img src="images/bisect/bisect-cherry-pick-2.svg"
alt="Undo R' and return to commit D">
</section>
<section class="image" data-transition="none">
<h3>Give feedback about <code>D</code></h3>
<pre>$ git bisect <span class="highlight">bad</span></pre>
<img src="images/bisect/bisect-cherry-pick-4.svg"
alt="Give git feedback about the test result">
</section>
<section class="image" data-transition="none">
<h3>Repeat!</h3>
<pre>$ git cherry-pick <span class="highlight">repro</span></pre>
<img src="images/bisect/bisect-cherry-pick-5.svg"
alt="Give git feedback about the test result">
</section>
</section>
<section>
<section>
<h1>Documentation</h1>
</section>
<section>
<h2>Written by Experts</h2>
<a href="http://git-scm.com/docs"
target="_blank">
<img src="images/docs/le-petit-robert.png"
alt="Le Petit Robert"
style="height: 450px">
</a>
<blockquote style="margin-top: 0">
git-rebase - Forward-port local commits to the updated upstream head
<footer>
<cite>— <a href="https://git-scm.com/docs/git-rebase/2.6.5" target="_blank">git-rebase 2.6.5 manpage</a></cite>
</footer>
</blockquote>
</section>
<section>
<a href="http://git-scm.com/book/en/v2"
target="_blank">
<img src="images/docs/pro-git.png" alt="Pro Git">
</a>
</section>
</section>
<section>
<section>
<h1>Image Credits</h1>
</section>
<section>
<ul class="inline-images">
<li>
<a href="#/">
<img src="images/git-logo.svg" alt="Git logo">
Git Logo
</a>
by
<a href="https://twitter.com/jasonlong">Jason Long</a>
is licensed under the
<a href="https://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution 3.0 Unported License</a>
</li>
<li>
<a href="#/">
<img src="//imgs.xkcd.com/comics/git.png" alt="xkcd">
Git Comic
</a>
by
<a href="https://xkcd.com/1597/">xkcd</a>
is licensed under the
<a href="https://creativecommons.org/licenses/by-nc/2.5/">Creative Commons Attribution-NonCommercial 2.5 Generic License</a>
</li>
<li>
<a href="#/">