-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathversion-control-with-git.html5.html
1984 lines (1480 loc) · 56.8 KB
/
version-control-with-git.html5.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>
<!--
Copyright 2010 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Original slides: Marcin Wichary ([email protected])
Modifications: Ernest Delgado ([email protected])
Alex Russell ([email protected])
Brad Neuberg
-->
<!-- modifications for s9 template:
removed offline manifest
removed disclaimer; it's just a prototype anyway
removed google analytics script code
removed all slides
changed default list-style from none to square
-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<title>Version Control with Git</title>
<link href=' http://fonts.googleapis.com/css?family=Droid+Sans|Droid+Sans+Mono' rel='stylesheet' type='text/css'>
<!-- <link type="text/css" href="./src/scrollbar.css" rel="stylesheet"> -->
<style>
.notes { display: none; }
.stroke {
-webkit-text-stroke-color: red;
-webkit-text-stroke-width: 1px;
-moz-text-stroke-color: red;
-moz-text-stroke-width: 1px;
}
body {
font: 14px "Lucida Grande", "Trebuchet MS", Verdana, sans-serif;
padding: 0;
margin: 0;
width: 100%;
height: 100%;
position: absolute;
left: 0px; top: 0px;
}
.presentation {
position: absolute;
height: 100%;
width: 100%;
left: 0px;
top: 0px;
display: block;
overflow: hidden;
background: #778;
}
.slides {
width: 100%;
height: 100%;
/*
overflow: hidden;
*/
left: 0;
top: 0;
position: absolute;
display: block;
-webkit-transition: -webkit-transform 1s ease-in-out;
-moz-transition: -moz-transform 1s ease-in-out;
-o-transition: -o-transform 1s ease-in-out;
}
.slide {
display: none;
position: absolute;
overflow: hidden;
width: 900px;
height: 700px;
left: 50%;
top: 50%;
margin-top: -350px;
background: -webkit-gradient(linear, left bottom, left top, from(#bbd), to(#fff));
-webkit-transition: margin 0.25s ease-in-out;
background-color: #eee;
background: -moz-linear-gradient(bottom, #bbd, #fff);
-moz-transition: margin 0.25s ease-in-out;
-o-transition: margin 0.25s ease-in-out;
}
.slide:nth-child(even) {
border-top-left-radius: 20px;
-moz-border-radius-topleft: 20px;
-webkit-border-top-left-radius: 20px;
border-bottom-right-radius: 20px;
-moz-border-radius-bottomright: 20px;
-webkit-border-bottom-right-radius: 20px;
}
.slide:nth-child(odd) {
border-top-right-radius: 20px;
-moz-border-radius-topright: 20px;
-webkit-border-top-right-radius: 20px;
border-bottom-left-radius: 20px;
-moz-border-radius-bottomleft: 20px;
-webkit-border-bottom-left-radius: 20px;
}
.slide p {
font-size: 20px;
}
.slide .counter {
color: #999999;
position: absolute;
left: 20px;
bottom: 20px;
display: block;
font-size: 12px;
}
.slide.title > .counter,
.slide.segue > .counter,
.slide.mainTitle > .counter {
display: none;
}
section.intro p {
font-size: 35px;
}
button {
font-size: 20px;
}
.summary {
font-size: 30px;
}
.bullets {
font-size: 40px;
}
.slide.far-past {
display: block;
margin-left: -2400px;
}
.slide.past {
display: block;
margin-left: -1400px;
}
.slide.current {
display: block;
margin-left: -450px;
}
.slide.future {
display: block;
margin-left: 500px;
}
.slide.far-future {
display: block;
margin-left: 1500px;
}
body.three-d div.presentation {
/*background: -webkit-gradient(radial, 50% 50%, 10, 50% 50%, 1000, from(#333), to(#000)); */
}
body.three-d div.slides {
-webkit-transform: translateX(50px) scale(0.8) rotateY(10deg);
-moz-transform: translateX(50px) scale(0.8) rotateY(10deg);
-o-transform: translateX(50px) scale(0.8) rotateY(10deg);
}
/* Content */
@font-face { font-family: 'Junction'; src: url(src/Junction02.otf); }
@font-face { font-family: 'LeagueGothic'; src: url(src/LeagueGothic.otf); }
header {
font-family: 'Droid Sans';
font-weight: normal;
font-size: 50px;
letter-spacing: -.05em;
color: white;
color: black;
text-shadow: rgba(0, 0, 0, 0.2) 0 2px 5px;
position: absolute;
left: 30px;
top: 25px;
margin: 0;
padding: 0;
}
.intro h1 {
color: black;
padding: 0;
margin: 0;
letter-spacing: -2px;
font-size: 96px;
}
.intro h2 {
color: black;
padding: 0;
margin: 0;
margin-top: -5px;
font-size: 40px;
letter-spacing: -1px;
}
h1 {
display: inline;
font-size: 100%;
font-weight: normal;
padding: 0;
margin: 0;
}
h2 {
font-family: 'Droid Sans';
color: black;
font-size: 20px;
margin-left: 20px;
margin-top: 50px;
}
h2:first-child {
margin-top: 0;
}
section {
font-family: 'Droid Sans';
font-size: 50px;
color: #3f3f3f;
text-shadow: rgba(0, 0, 0, 0.2) 0 2px 5px;
margin-left: 30px;
margin-right: 30px;
margin-top: 100px;
display: block;
overflow: hidden;
}
a {
color: inherit;
display: inline-block;
text-decoration: none;
line-height: 110%;
border-bottom: 2px solid #3f3f3f;
}
#wmap a {
line-height: 100%;
border-bottom: none;
}
section.left {
float: left;
width: 390px;
}
section.small {
font-size: 24px;
}
section.small ul {
margin: 0 0 0 15px;
padding: 0;
}
section.small li {
padding-bottom: 0;
}
h2 {
padding: 0;
margin: 15px 0 5px 0;
/* font-family: GG240;*/
}
section.center {
line-height: 180%;
text-align: center;
display: table-cell;
vertical-align: middle;
height: 700px;
width: 900px;
}
pre {
text-align: left;
font-size: 16px;
font-family: 'Droid Sans Mono', Courier;
padding-bottom: 10px;
padding: 10px 20px;
background: rgba(255, 0, 0, 0.05);
border-radius: 8px;
border: 1px solid rgba(255, 0, 0, 0.2);
}
.two-column {
-webkit-column-count: 2;
-moz-column-count: 2;
}
pre select {
font-size: 16px;
font-family: Monaco, Courier;
border: 1px solid #c61800;
}
input {
font-size: 16px;
font-family: Helvetica;
padding: 3px;
}
input[type="range"] {
width: 100%;
}
button {
font-family: Verdana;
}
button.large {
font-size: 32px;
}
pre b {
font-weight: normal;
color: #c61800;
text-shadow: #c61800 0 0 1px;
/*letter-spacing: -1px;*/
}
pre em {
font-weight: normal;
font-style: normal;
color: #18a600;
text-shadow: #18a600 0 0 1px;
}
pre input[type="range"] {
height: 6px;
cursor: pointer;
width: auto;
}
example {
font-size: 16px;
display: block;
padding: 10px 20px;
color: black;
background: rgba(255, 255, 255, 0.4);
border-radius: 8px;
margin-bottom: 10px;
border: 1px solid rgba(0, 0, 0, 0.2);
}
video {
border-radius: 8px;
border: 1px solid rgba(0, 0, 0, 0.2);
}
.css,
.js,
.html,
.key {
font-family: 'Droid Sans';
color: black;
display: inline-block;
padding: 6px 10px 3px 10px;
font-size: 25px;
line-height: 30px;
text-shadow: none;
letter-spacing: 0;
bottom: 10px;
position: relative;
border-radius: 10px;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
background: white;
box-shadow: rgba(0, 0, 0, 0.1) 0 2px 5px;
-webkit-box-shadow: rgba(0, 0, 0, 0.1) 0 2px 5px;
-moz-box-shadow: rgba(0, 0, 0, 0.1) 0 2px 5px;
}
.key { font-family: Arial; }
:not(header) > .css,
:not(header) > .js,
:not(header) > .html,
:not(header) > .key {
margin: 0 5px;
bottom: 4px;
}
.css {
background: -webkit-gradient(linear, left top, left bottom, from(#ff4), to(#ffa));
background-color: #ff4;
background: -moz-linear-gradient(left top, #ff4, #ffa);
}
.js {
background: -webkit-gradient(linear, left top, left bottom, from(#4f4), to(#afa));
background-color: #4f4;
background: -moz-linear-gradient(left top, #4f4, #afa);
}
.html {
background: -webkit-gradient(linear, left top, left bottom, from(#e88), to(#fee));
background-color: #e88;
background: -moz-linear-gradient(left top, #e88, #fee);
}
li {
list-style: square;
padding: 10px 0;
}
.summary li::before, .bullets li::before {
content: '· ';
}
info {
display: block;
font-size: 50%;
text-align: center;
}
</style>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
</head><body>
<div class="presentation">
<div class="slides">
<div class="slide">
<section class="center intro">
<p>This presentation is an HTML5 website</p>
<p>Press <span class="key">→</span> key to advance.</p>
<p>Zoom in/out: <span class="key">Ctrl or Command</span> + <span class="key">+/-</span></p>
</section>
</div>
<div class="slide">
<header></header>
<section class="small">
<!-- _S9SLIDE_ -->
<p><img src="img/main-slide.png" alt="main" /></p>
</section>
</div>
<div class="slide">
<header><h1 id="who-am-i">Who am I?</h1></header>
<section class="small">
<ul>
<li>Jeroen Budts</li>
<li>PHP & Drupal Developer</li>
<li>At <a href="http://inuits.eu">Inuits</a> - An Open Source Consultancy Company</li>
<li><a href="http://budts.be">http://budts.be</a></li>
<li>Twitter: @teranex</li>
<li>Father</li>
</ul>
<p><img src="img/lotte-git.jpg" alt="lotte-git" /></p>
</section>
</div>
<div class="slide">
<header><h1 id="overview">Overview</h1></header>
<section class="small">
<ul>
<li>Basic Git usage</li>
<li>How Git stores it’s stuff</li>
<li>More advanced Git usage
(branching, merging, rebasing, remotes, …)</li>
<li>Some cool Git tools</li>
</ul>
</section>
</div>
<div class="slide">
<header><h1 id="what-is-git">What is Git?</h1></header>
<section class="small">
<blockquote>
<p>“Git is a free & open source, distributed version control system designed to
handle everything from small to very large projects with speed and efficiency.” </p>
</blockquote>
<ul>
<li>Distributed</li>
<li>Open Source</li>
<li>Fast</li>
<li>Created by Linus Torvalds (Linux)</li>
</ul>
</section>
</div>
<div class="slide">
<header><h1 id="basic-git-usage">Basic Git Usage</h1></header>
<section class="small">
<p>First initialize the git repository:</p>
<pre><code>git init
</code></pre>
<p>Then add files</p>
<pre><code>git add -A
# or
git add .
# or
git add myfile.txt
git add myotherfile.rb
</code></pre>
<p>And commit the files</p>
<pre><code>git commit
</code></pre>
</section>
</div>
<div class="slide">
<header><h1 id="the-index-staging-area">The Index (Staging Area)</h1></header>
<section class="small">
<p>The index contains the changes to will be added to your next commit. Your commit will /not/ contain the changes in your working directory. Only the changes that were added to the index!</p>
<p><img src="img/git-02.png" alt="git-02" /></p>
</section>
</div>
<div class="slide">
<header><h1 id="the-index-staging-area-1">The Index (Staging Area)</h1></header>
<section class="small">
<p>If you add a file, or a part of a file, to the index, a copy is made of that file. When you commit, it is that copy which ends up in the commit.</p>
<p><strong>Important</strong>: if you make changes to the file after adding it to the index, those changes will
not end up in your commit, unless you add the file again to the index!</p>
<pre><code>`git diff`
# shows the diff of your working copy
`git diff --cached`
# show the diff of your index
</code></pre>
<p>If you modify files, you need to ‘<em>stage</em>’ them again, by running <code>git add</code>. </p>
<p>If you only modified files (not added new ones) you can skip staging with:</p>
<pre><code>git commit -a
</code></pre>
<p>You can also add only parts of a modified file:</p>
<pre><code>git add -p myfile.txt
</code></pre>
</section>
</div>
<div class="slide">
<header><h1 id="the-index-staging-area-2">The Index (Staging Area)</h1></header>
<section class="small">
<pre><code>git status # show the status of your repo
</code></pre>
<p><img src="img/git-18.png" alt="git-18" /></p>
</section>
</div>
<div class="slide">
<header><h1 id="viewing-the-history">Viewing the history</h1></header>
<section class="small">
<pre><code>git log
</code></pre>
<p><img src="img/git-13.png" alt="git-13" /></p>
</section>
</div>
<div class="slide">
<header><h1 id="viewing-the-history-1">Viewing the history</h1></header>
<section class="small">
<p><code>git log</code> has many options. The following:</p>
<pre><code>git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset \
%s %Cgreen(%cr) %C(bold blue)an>%Creset' --abbrev-commit --date=relative
</code></pre>
<p>Will give you this, which gives <strong>a lot</strong> more information</p>
<p><img src="img/git-11.png" alt="git-11" /></p>
<p>Tip: add this in your global gitconfig as an alias: ~/.gitconfig</p>
<pre><code>[alias]
l = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s
%Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
</code></pre>
</section>
</div>
<div class="slide">
<header><h1 id="undoing-changes">Undoing changes</h1></header>
<section class="small">
<h2 id="checkout">Checkout</h2>
<p>Checkout a single file. Notice the dashes: <code>git checkout</code> is also used in other cases, this makes it clear to Git that you are pointing to a single file.</p>
<pre><code>git checkout -- /path/to/file # restore version from index
git checkout HEAD /path/to/file # restore to latest committed version
</code></pre>
<h2 id="reset">Reset</h2>
<p>Reset your branch to a commit and all the changes in your working copy</p>
<pre><code>git reset [--hard]
</code></pre>
<h2 id="revert">Revert</h2>
<p>Write a reversed version of an existing commit. This is very useful if you have already pushed the commit</p>
<pre><code>git revert [commit-sha]
</code></pre>
<h2 id="rebase">Rebase</h2>
<p>We’ll discuss this later</p>
</section>
</div>
<div class="slide">
<header><h1 id="how-git-stores-your-data">How Git stores your data</h1></header>
<section class="small">
<p>Knowing how Git stores all your data will give you a better understanding of the fundamentals and Git will become a lot more predictable</p>
<p>The most important point to remember: </p>
<p><strong>Basically a Git repository is a database of objects</strong></p>
</section>
</div>
<div class="slide">
<header><h1 id="how-git-stores-your-data-1">How Git stores your data</h1></header>
<section class="small">
<p>The most important types of objects:</p>
<ul>
<li>blobs</li>
<li>trees</li>
<li>commits</li>
</ul>
<p>Let’s study those in a bit more detail</p>
</section>
</div>
<div class="slide">
<header><h1 id="blobs">Blobs</h1></header>
<section class="small">
<p>Git stores the <em>contents</em> of a file in a ‘blob’.</p>
<ul>
<li>does not contain any meta data</li>
<li>a blob never changes</li>
<li>a hash is calculated as the blob name</li>
<li>the hash will always be the same for the same contents</li>
</ul>
<p>some examples:</p>
<pre><code>$ git hash-object hello.txt
ce6c1fd146f65c899e6b10e46c89097c644e3229
$ git hash-object say-hi.rb
a8784b043f12b4b0c9114c55ebf33f5c9b44ce8f
</code></pre>
</section>
</div>
<div class="slide">
<header><h1 id="trees">Trees</h1></header>
<section class="small">
<p>A tree is a like a directory</p>
<ul>
<li>Can contain references to 1 or more blobs</li>
<li>Can contain references to 0, 1 or more other trees</li>
<li>Contains the meta data about the files</li>
<li>Itself also identified by a hash</li>
</ul>
<p><img src="img/git-03_2.png" alt="git-03" /></p>
</section>
</div>
<div class="slide">
<header><h1 id="commits">Commits</h1></header>
<section class="small">
<p>If you think about Git, think about commits!</p>
<ul>
<li>Contains a reference to one tree object</li>
<li>Contains references to one or more other commits
<ul>
<li>one exception: the very first commit in the repo</li>
</ul>
</li>
<li>A commit usually points to it’s parent commit</li>
<li>In case of a merge, it can point to two or more commits (one commit for each branch which you merged together)</li>
</ul>
</section>
</div>
<div class="slide">
<header><h1 id="commits-1">Commits</h1></header>
<section class="small">
<p><img src="img/git-04.png" alt="git-04" /></p>
<p>Did I mention that you should think in terms of commits, when working with Git? </p>
<p>If you understand commits, you basically understand Git.</p>
</section>
</div>
<div class="slide">
<header><h1 id="git-references-or-refs">Git References or “refs”</h1></header>
<section class="small">
<p>Because a commit hash is very difficult to remember and not really useful to work with, Git uses references to point to specific commits.</p>
<h2 id="head">HEAD</h2>
<p>One such reference is <strong>HEAD</strong></p>
<ul>
<li>It points to the commit which is currently checked out into your working directory</li>
</ul>
<h2 id="master">master</h2>
<p>Another important reference is <strong>master</strong></p>
<ul>
<li>master is the ‘default’ branch in Git</li>
<li>when working on the master branch, the master reference and the HEAD reference point to the same commit</li>
</ul>
<h2 id="special">special</h2>
<ul>
<li><strong>HEAD^ & HEAD^^</strong>: The commit before HEAD, two commits before HEAD</li>
<li><strong>master~7</strong>: 7 commits before master reference</li>
</ul>
<p>And that brings us to…</p>
</section>
</div>
<div class="slide">
<header><h1 id="branches">Branches</h1></header>
<section class="small">
<p>Branches in Git are basically just references to other commits</p>
<ul>
<li>very easy to create</li>
<li>once you get the hang of it, you will probably create branches for almost every feature you want to implement</li>
<li>a branch has a name</li>
<li>this name is also the reference to the most recent commit for that branch</li>
<li>a commit can be shared by branches</li>
<li>The point where a branch is split of from another branch, can be found by following the parents of all the commits until you find a common commit</li>
</ul>
</section>
</div>
<div class="slide">
<header><h1 id="branches-1">Branches</h1></header>
<section class="small">
<p>Creating a branch and switching to it is easy:</p>
<pre><code>git branch mywork
git checkout mywork
</code></pre>
<p>The two previous commands can be combined:</p>
<pre><code>git checkout -b mywork
</code></pre>
<p>This will create a branch and immediately check it out.</p>
<p>Once you have merged your work on a specific feature back into your master branch you can delete your feature branch:</p>
<pre><code>git branch -d mywork
</code></pre>
</section>
</div>
<div class="slide">
<header><h1 id="branches-2">Branches</h1></header>
<section class="small">
<ul>
<li>We are working on a branch named ‘origin’</li>
<li>At commit C2 we decide to split off a new branch named ‘mywork’.</li>
<li>Both branches originate from commit C2; commit C3 and C5 have the same parent</li>
</ul>
<p><img src="img/git-05.png" alt="git-05" /></p>
</section>
</div>
<div class="slide">
<header><h1 id="merging">Merging</h1></header>
<section class="small">
<p>When you have been working on a (feature) branch for a while you will probably want to merge those branches back together.</p>
<pre><code># to merge the origin branch back into your mywork branch (to bring it up to date)
# checkout the target branch
git checkout mywork
# merge the branch into the current branch
git merge origin
</code></pre>
<p>Now your repository looks like this: (Notice that commit C7 has two parents)
<img src="img/git-06.png" alt="git-06" /></p>
</section>
</div>
<div class="slide">
<header><h1 id="merging-1">Merging</h1></header>
<section class="small">
<p>When merging two or more branches there are two possibilities:</p>
<ul>
<li>Merge commit</li>
<li>Fast Forward </li>
</ul>
<h2 id="merge-commit">Merge commit</h2>
<ul>
<li>When both branches have new commits a merge commit is created.</li>
<li>
<p>Git automatically proposes a commit message: </p>
<p><code>Merge branch 'mywork' into master</code></p>
</li>
<li>The commit has two or more parents</li>
</ul>
</section>
</div>
<div class="slide">
<header><h1 id="merging-2">Merging</h1></header>
<section class="small">
<h2 id="fast-forward">Fast Forward</h2>
<ul>
<li>When the target branch does not have new commits</li>
<li>No merge commit is created</li>
<li>In fact nothing much happens</li>
<li>Except: The reference for the target branch is simply changed to point the same commit as the source branch</li>
<li>This is an ideal situation and can never go wrong</li>
<li>Obviously you are not always this lucky (→ rebasing)</li>
</ul>
</section>
</div>
<div class="slide">
<header><h1 id="merging-3">Merging</h1></header>
<section class="small">
<h2 id="fast-forward-1">Fast Forward</h2>
<p><img src="img/git-07-before.png" alt="git-07-before" /> Merge the ‘mywork’ branch into origin
<img src="img/git-07-after.png" alt="git-07-after" /> The origin branch is simply fast-forwarded</p>
</section>
</div>
<div class="slide">
<header><h1 id="rebasing">Rebasing</h1></header>
<section class="small">
<p>Instead of merging (with merge commits) you can also rebase (so you can then fast forward)</p>
<p>Some people will tell you that this is very harmful, it can break your repository and destroy the universe.<br />
This is <strong>NOT TRUE</strong>. (At least if you know what you are doing)</p>
<h2 id="so-what-is-rebasing">So what is ‘rebasing’?</h2>
<p>By rebasing your commits you can actually rewrite your history:</p>
<ul>
<li>Edit a commit message</li>
<li>Add missing files to a commit</li>
<li>Reorder your commits</li>
<li>Modify the parent of a commit</li>
<li>Merge a few commits together into a single commit</li>
<li>Delete commits from the history</li>
<li>…</li>
<li>And break your repository if you want :)</li>
</ul>
</section>
</div>
<div class="slide">
<header><h1 id="rebasing-1">Rebasing</h1></header>
<section class="small">
<h2 id="how-not-to-break-your-repo">How not to break your repo?</h2>
<p>Do not rebase commits which have already been pushed to other people </p>
<p>Do not rebase commits which have already been pushed to other people </p>