forked from spyl94/formation-git
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
805 lines (633 loc) · 31 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
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>Git Tutorial • Alexis Fouche</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">
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/animate.min.css">
<link rel="stylesheet" href="css/theme/sky.css" id="theme-basis">
<link rel="stylesheet" href="css/theme/pw14.css" id="theme">
<!-- For syntax highlighting -->
<link rel="stylesheet" href="lib/css/tomorrow.css">
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body id="prioFix">
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<section>
<h2>If you only knew the power of <a href="#">Git</a> !</h2>
<p>
<small><em>Inspired by:
<ul>
<li><a href="http://twitter.com/spyl94">Aurélien David</a></li>
<li><a href="http://delicious-insights.com/talks/blend2014-git-protips">Git Protips</a> by <a href="http://twitter.com/porteneuve">@porteneuve</a></li>
</ul></em></small>
</p>
</section>
<section id="whoami">
<h2>1. <a href="#/git">The Basics</a></h2>
<h2>2. <a href="#/branches">Branches</a></h2>
<h2>3. <a href="#/pro-tips">Pro Tips</a></h2>
</section>
<section data-state="theme-color-blue-yellow">
<section id="git">
<h1>Git ?</h1>
<h3>Distributed Version Control</h3>
<p>Easy to learn</p>
<p>Lightning fast performance</p>
<p><em>Created by Linus Torvalds</em></p>
</section>
<section id="git-decentralise">
<h3>Distributed Version Control</h3>
<img src="img/decentralise.png" alt="">
</section>
<section id="github">
<h3>Github</h3>
<img src="img/github-zniehgames.png" alt="">
<p>
<a href="https://help.github.com/articles/set-up-git/">Set Up Git</a> - <a href="https://help.github.com/articles/create-a-repo/"> Create a Repo</a> - <a href="https://help.github.com/articles/using-pull-requests/"> Using pull requests</a>
</p>
</section>
<section id="github-social">
<h3>Be social !</h3>
<p>Follow me : <a href="https://github.com/alfoeternia/">alfoeternia</a> :-)</p>
<p>Star your favorite repositories :</p>
<a href="https://github.com/twbs/bootstrap">twbs/bootstrap</a> -
<a href="https://github.com/angular/angular.js">angular/angular.js</a> -
<a href="https://github.com/mbostock/d3">mbostock/d3</a>
<a href="https://github.com/robbyrussell/oh-my-zsh">robbyrussell/oh-my-zsh</a> -
<a href="https://github.com/moment/moment">moment/moment</a> -
<a href="https://github.com/docker/docker">docker/docker</a>
<a href="https://github.com/hakimel/reveal.js">hakimel/reveal.js</a> -
<a href="https://github.com/facebook/react">facebook/react</a> -
<a href="https://github.com/symfony/symfony">symfony/symfony</a>
<a href="https://github.com/google/material-design-icons">google/material-design-icons</a> -
<a href="https://github.com/git/git">git/git</a> -
<a href="https://github.com/antirez/redis">antirez/redis</a>
</section>
<section id="create-repository">
<h3>Set up a new repository</h3>
<h5>Demo</h5>
<p>Need help ? <a href="https://help.github.com/articles/create-a-repo/">GitHub explains it all!</a></p>
</section>
<section id="basic-usage">
<h3>Basic Usage</h3>
<img style="background: white" src="img/basic-usage.png" alt="">
<p>Everything here is <strong>in local</strong>, on your machine!</p>
</section>
<section id="file-status-lifecycle">
<h3>Life cycle</h3>
<img style="background: white" src="img/file-status-lifecycle.png" alt="">
</section>
<section id="status">
<h3>Status</h3>
<p>The most useful tool. Just use it every time...</p>
<p class="breathing"><code>git status</code></p>
</section>
<section id="commits-stage" data-duration="1m">
<h2>Staging</h2>
<p>The <span lang="en">stage</span> or index : what will be included in the next commit.</p>
<p class="breathing"><code>git add <em>pathspec…</em></code> = « add <em>pathspec</em> to the staging area ».</p>
<p><strong>Mandatory</strong> when adding a <strong>new</strong> file (<span lang="en">untracked</span>).</p>
</section>
<section id="commits-add-all" data-duration="45s">
<h2>Add everything to the stage</h2>
<p><code>git add .</code> was not enough before Git 2.0 : it doesn't take into account the <span lang="en">working directory</span>, which means deletions are not supported.</p>
<pre><code data-trim data-noescape class="no-highlight">
Changes not staged for commit:
…
<span class="red"><u>deleted</u>: index.html</span>
<u>Untracked</u> files:
…
<span class="red">home.html</span>
</code></pre>
<p class="breathing">To manage knowns <strong>and</strong> <span lang="en">untracked</span> files, we use <code>-A</code> (<code>--all</code>)</p>
<pre><code data-trim data-noescape class="bash">
<span class="blue">$ git add <u>-A</u> && git status</span>
On branch master
Changes to be committed:
…
<span class="green"><u>renamed</u>: index.html -> home.html</span>
</code></pre>
</section>
<section id="commits-diff-staged" data-duration="30s">
<h2>See the <span lang="en">staged area</span></h2>
<pre><code data-trim data-noescape class="no-highlight">
<span class="blue">$ git diff <u>--staged</u></span>
<span class="yellow">diff --git c/index.html i/index.html
index 5237399..85e642f 100644
--- c/index.html
+++ i/index.html
@@ -1,5 +1,5 @@</span>
<!doctype html>
<span class="red">-<html></span>
<span class="green">+<html lang="fr"></span>
</code></pre>
</section>
<section id="commit-messages" data-duration="30s">
<h2>Commit the stage</h2>
<pre><code data-trim data-noescape class="no-highlight">
<span class="blue">$ git commit</span>
</code></pre>
<p>You have to include a message to explain your work:</p>
<pre><code data-trim data-noescape class="no-highlight">
Capitalized, short (50 chars or less) summary
More detailed explanatory text, if necessary. Wrap it to about 72
characters or so. In some contexts, the first line is treated as the
subject of an email and the rest of the text as the body. The blank
line separating the summary from the body is critical (unless you omit
the body entirely); tools like rebase can get confused if you run the
two together.
Write your commit message in the imperative: "Fix bug" and not
"Fixed bug" or "Fixes bug." This convention matches up with commit
messages generated by commands like git merge and git revert.
Further paragraphs come after blank lines.
</code></pre>
<pre><code data-trim data-noescape class="no-highlight">
$ git commit <span class="blue">-m</span> <span class="green">'commit message of a lazy developer'</span>
</code></pre>
<p>After a commit, <strong>the stage is empty</strong>.</p>
</section>
<section id="demo" data-duration="30s">
<h2>Working in local</h2>
<p>git status, git add, git diff and git commit in action!</p>
<br>
<h5>Demo</h5>
</section>
<section id="push" data-duration="30s">
<h2>Share your work</h2>
<p>
When you believe your work is done you can push your commits to the remote repository : <br>
<code>git push [distant-name] [branch-name]</code> <br>
</p>
<pre><code data-trim data-noescape class="no-highlight">
<span class="blue">$ git push origin master</span>
</code></pre>
</section>
<section id="push" data-duration="30s">
<h2>Fetch from the remote repo</h2>
<p>
<code>git fetch [distant-name]</code> fetch the update source code from the repository, while <code>git pull [distant-name] [branch-name]</code> automatically merge your work with the remote source.
</p>
<pre><code data-trim data-noescape class="no-highlight">
<span class="blue">$ git pull origin master</span>
</code></pre>
</section>
<section id="push-demo" data-duration="30s">
<h3>Collaborate with Git</h3>
<h5>Demo</h5>
</section>
</section>
<section data-state="theme-color-silver-green">
<section id="branches">
<h1>Branches</h1>
</section>
<section id="branches-what">
<h4>Why ?</h4>
<p>Branches are used to develop features isolated from each others.</p>
<p>By default, la main branch is named <code>master</code>.</p>
<h4>One branch by feature</h4>
<p>You should always work in a branch different from <code>master</code> (ex: <code>add-registration-form</code>, <code>fix-bug-123</code>), then merge your branches inside <em>master</em>.</p>
</section>
<section id="git-pr">
<p>Wait... not so fast!</p>
<br>
<h3>Pull Request</h3>
<h3>=</h3>
<h3>Asking to merge</h3>
<h3>=</h3>
<h3>Code + Issue + Comments</h3>
<p>Perfect for code reviews!</p>
</section>
<section id="git-pr-example">
<img src="img/pr-example.png" alt="">
</section>
<section id="github-workflow">
<h2>Workflow #1 : simple</h2>
<img src="img/github-workflow.jpg" alt="">
<p>Adapted to continuous deployment</p>
</section>
<section id="scrum-workflow">
<h2>Workflow #2 : scrum</h2>
<img src="img/workflow-scrum.png" alt="">
</section>
<section id="branches-checkout-b" data-duration="45s">
<h2>Create a branch</h2>
<p>Most of the time, when you create a branch, you immediately want to work on it.</p>
<pre><code data-trim data-noescape class="no-highlight">
<b class="wrong">(master) $ git branch feature
(master) $ git checkout feature
(feature) $</b>
</code></pre>
<pre><code data-trim data-noescape class="no-highlight">
<b class="right">(master) $ git <u>checkout -b</u> feature
(feature) $</b>
</code></pre>
<p>Note that to start working on a remote branch you only need a <code>checkout</code>.</p>
<pre><code data-trim data-noescape class="no-highlight">
<span class="blue">(master) $ git branch -a</span>
* <span class="green">master</span>
<span class="red">origin/master</span>
<span class="red">origin/topic</span>
<span class="blue">(master) $ git checkout topic</span>
Branch topic set up to track remote branch topic from origin.
Switched to a new branch 'topic'
<span class="blue">(topic) $</span>
</code></pre>
</section>
<section id="branches-vv-a" data-duration="45s">
<h2>List the branches</h2>
<p>Two useful options for <code>git branch</code> :</p>
<p><code>-a</code> list all local <em>and</em> remote branches</p>
<p><code>-vv</code> add the first line of the last commit</p>
<pre><code data-trim data-noescape class="no-highlight barely-smaller">
<span class="blue">(2014-october u+1) $ git branch -avv</span>
* <span class="green">2014-octobre</span> abaca0f [<span class="blue">origin/2014-octobre: ahead 1</span>] Removed all demos
legacy 41b5bf7 [<span class="blue">origin/legacy</span>] Bash script for deployment
master 0208acb [<span class="blue">origin/master</span>] Fix .groc.json
v2014 521350a [<span class="blue">origin/v2014</span>: behind 2] Backport target link from Backbone to backplug.io
v2015 27b1791 [<span class="blue">origin/v2015</span>] Documents updated
<span class="red">remotes/origin/2014-octobre</span> 10ad1b1 Commented source code
<span class="red">remotes/origin/bs3-basis</span> 650f025 Export connectivity tweaks
…
</code></pre>
</section>
<section id="branches-merge" data-duration="3m">
<h2>Merges</h2>
<!--<p>On ne fusionne que pour rappatrier de <strong>façon visible</strong> (bosse dans le graphe) un <strong>périmètre fonctionnel identifié</strong> (bugfix, feature, story, etc.).</p>-->
<pre><code data-trim data-noescape class="no-highlight">
<span class="blue">(master) $ git merge awesome-feature</span>
</code></pre>
<!-- <p>La branche est un descendant ? Empêchez le fast-forward :</p>
<pre><code data-trim data-noescape class="no-highlight">
<span class="blue">(master) $ git merge <u>--no-ff</u> awesome-feature</span>
</code></pre>
<p>Illustration de la différence au prochain slide !</p> -->
</section>
<section id="branches-merge-no-ff" data-duration="3m">
<img src="img/merge-ff-vs-no-ff.png" alt="">
</section>
<section id="branches-conflict-method" data-duration="3m">
<h2>Solve a conflict</h2>
<!-- Méthodo : status, éditeur, add, finalisation -->
<p>Most of the conflicts are <strong>simple to solve</strong>.</p>
<p>Here is the workflow:</p>
<ol>
<li><code>git status</code> firstly (to know what happened)</li>
<li>Examine the 1st conflicted file (<code>git mergetool</code>)</li>
<li>Fix the conflict</li>
<li><code>git add</code> to mark the conflict of the file as resolved</li>
<li>If conflicting files remaining, go to (2).</li>
<li>Else, <code>git commit</code>.</li>
</ol>
</section>
<section id="branches-conflictstyle" data-duration="45s">
<h2>What does a conflict look like?</h2>
<pre><code data-trim data-noescape class="no-highlight">
<<<<<<< HEAD
SVN is a widespread and extremely convenient
source management tool.
=======
SVN is a widespread and extremely convenient
source management tool despite his profound stupidity.
>>>>>>> truth
</code></pre>
</section>
<section id="branches-conflictstyle" data-duration="45s">
<h2>Solving it</h2>
<pre><code data-trim data-noescape class="no-highlight">
<b class="wrong"><<<<<<< HEAD
SVN is a widespread and extremely convenient
source management tool.
=======</b>
<b class="right">SVN is a widespread and extremely convenient
source management tool despite his profound stupidity.</b>
<b class="wrong">>>>>>>> truth</b>
</code></pre>
</section>
<section id="branches-merge-abort" data-duration="15s">
<h2>You wanna give up?</h2>
<pre><code data-trim data-noescape class="no-highlight">
<span class="blue">(master *) $ git merge <u>--abort</u></span>
<span class="blue">(master) $</span>
</code></pre>
</section>
<section id="branches-rebase" data-duration="45s">
<h2>Rebase</h2>
<p>Rebase our changes onto the distant branch.</p>
<pre><code data-trim data-noescape class="no-highlight">
<span class="blue">(awesome-feature) $ git rebase origin master</span>
</code></pre>
<p>Useful to fetch the latest bug fixes featuresm etc...</p>
</section>
<section id="branches-merge-vs-rebase" data-duration="45s">
<h2>Merge vs Rebase</h2>
<p>Initial situation</p>
<img src="img/branch-merge-hotfix.png" alt="">
<table style="width: 100%;">
<tr>
<td>With a merge...</td>
<td>With a rebase...</td>
</tr>
<tr>
<td><img src="img/branch-merge-feature.png" alt=""></td>
<td><img src="img/rebase-feature.png" alt=""></td>
</tr>
</table>
<p>Use <code>rebase</code> as mush as you want, but use <code>merge</code> only at the end!</p>
</section>
</section> <!-- #branches -->
<section data-state="theme-color-forest-yellow">
<!-- <section id="pushes-pull-merge" data-duration="1m30">
<h2>Pull ≠ Merge !</h2>
<p>Par défaut, <code>git pull</code> finit par un <code>merge</code>. C’est <strong><a href="http://www.git-attitude.fr/2014/05/04/bien-utiliser-git-merge-et-rebase/#le-piège de git pull et du réflexe pull + push">super con</a></strong>.</p>
<p>Quand tu pull, tu ne fusionnes pas une branche tierce chez toi : tu récupères les mises à jour sur ta branche courante.</p>
</section>
<section id="pushes-pull-rebase-preserve" data-duration="1m30">
<h2>Pull = Rebase</h2>
<p>Un <code>pull</code> devrait plutôt <strong>rejouer notre taf local sur la branche distante à jour</strong> : par définition, un <code>rebase</code>.</p>
<pre><code data-trim data-noescape class="no-highlight">
<span class="blue">$ git pull --rebase origin master</span>
</code></pre>
<p>Il faut juste <a href="http://www.git-attitude.fr/2014/05/04/bien-utiliser-git-merge-et-rebase/#le-cas épineux du pull qui rebase un merge local">faire attention</a> à ne pas <span lang="en">inliner</span> par inadvertance un <code>merge</code> au sein du travail local.</p>
<p>Une bonne fois pour toutes :</p>
<pre><code data-trim data-noescape class="no-highlight">
<span class="blue">$ git config --global <u>pull.rebase preserve</u></span>
</code></pre>
</section> -->
<section id="commits-amend" data-duration="2m">
<h2>Modify</h2>
<h3>the latest commit</h3>
<p class="breathing"><code>git commit --amend</code> <strong>replaces</strong> by the current state.</p>
<p>Forgot to add a dependency?</p>
<pre><code data-trim data-noescape class="bash">
<span class="blue">$ git <u>add</u> vendor/scripts/underscore.min.js
$ git commit <u>--amend --no-edit</u></span>
</code></pre>
<p>Forgot to remove a sensitive file?</p>
<pre><code data-trim data-noescape class="bash">
<span class="blue">$ git <u>rm --cached</u> config/database.yml
$ echo config/database.yml >> .gitignore && git add .gitignore
$ git commit --amend --no-edit</span>
</code></pre>
<p>Need to update the message ?</p>
<pre><code data-trim data-noescape class="bash">
<span class="blue">$ git commit --amend -m 'New message'</span>
</code></pre>
</section>
<section id="commits-stash-save" data-duration="1m30s">
<h2>The stash…</h2>
<pre><code data-trim data-noescape class="bash">
<span class="blue">(master <u>*+%</u>) $ <u>git stash save -u</u> 'migration BS3'</span>
Saved working directory and index state On master: migration BS3
HEAD is now at 8a5a383 Trackers GA asynchrones
<span class="blue">(master <u>$</u>) $</span>
</code></pre>
</section>
<section id="commits-stash-pop" data-duration="1m30s">
<h2>Unstash</h2>
<pre><code data-trim data-noescape class="bash">
<span class="blue">(master $) $ <u>git stash pop</u></span>
…
<span class="blue">(master *+%) $</span>
</code></pre>
<p class="breathing"><code>pop</code> tries to <code>apply</code> the stashed files, and finishes with a <code>drop</code>.</p>
</section>
<section id="pushes">
<h1>When to push?</h1>
</section>
<!-- <section id="pushes-default" data-duration="30s">
<h2>Faut pas pousser</h2>
<h3>les autres branches</h3>
<p>Par défaut, sur un <code>git push</code> seul, Git va tenter :</p>
<p>Avant 2.0 : toutes les branches trackées* de même nom**</p>
<p>Depuis 2.0 : l’actuelle si trackée de même nom**</p>
<p class="breathing">Ce qu’on veut : l’actuelle, quel que soit le nom distant.</p>
<pre><code data-trim data-noescape class="no-highlight">
$ git config --global <u>push.default upstream</u>
</code></pre>
<footer>
* push.default = matching — de même nom = nom distant identique au local<br>
** push.default = simple
</footer>
</section> -->
<section id="pushes-set-upstream" data-duration="1m30s">
<h2>Initial push</h2>
<h3>of a new branch</h3>
<pre><code data-trim data-noescape class="no-highlight">
<span class="blue">(stats-v3) $ git push <u>-u</u> origin stats</span>
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (5/5), 488 bytes | 0 bytes/s, done.
Total 5 (delta 0), reused 0 (delta 0)
To git@github.com:tdd/private-tests.git
* <u>[new branch] stats -> stats</u>
<b class="right">Branch stats set up to track remote branch stats from origin.</b>
</code></pre>
</section>
<!-- <section id="pushes-rebase-i" data-duration="5m">
<h2>Nettoyer avant push</h2>
<h3>Le bordel OK, mais chez toi</h3>
<p>Réflexe pré-push : nettoyer ton historique local, lequel est forcément plus ou moins en bordel.</p>
<pre><code data-trim data-noescape class="no-highlight">
$ git lg @{u}.. # show all commits that you have locally but not upstream
$ git rebase -i @{u}
</code></pre>
<p class="breathing">Le <strong>rebase interactif</strong> nous permet de mettre au propre nos travaux locaux avant de partager tout ça avec les copains.</p>
<p>Raison de plus pour <strong>ne pas faire de pushes trop souvent</strong>. On pond des commits souvent (10–30 ×/j), mais on push plus rarement (2–3 ×/j)</p>
<p>Danger : changer un historique déjà pushé ! A éviter sauf pour squash ces commits avant un merge.</p>
</section> -->
</section>
<section data-state="theme-color-asphalt-orange">
<section id="pro-tips">
<h1>Pro Tips</h1>
</section>
<section id="gitignore">
<h3>A file to ignore them all!</h3>
<p>We do not want to pollute the repo with libraries, heavy binaries, or with our config.</p>
<br>
<h3>.gitignore</h3>
<pre><code data-trim data-noescape class="no-highlight">
vendor/
node_modules/
app/config/parameter.yml
</code></pre>
<p>
<a href="https://www.gitignore.io/">gitignore.io</a>
</p>
</section>
<section id="commits-why-atomicity">
<h2>Atomic commits ?</h2>
<p>Do not put anything in your commits...</p>
<p>1 commit = 1 reduced permeter.</p>
<p class="breathing">To get there, one must master<code>add</code> and <code>reset</code>, but also <code>diff</code>, <code>show</code> and obviously <code>commit</code>.</p>
</section>
<!-- <section id="commits-status-untracked" data-duration="45s">
<h2>Un statut détaillé</h2>
<p>Voyez le détail des nouveaux fichiers, en profondeur.</p>
<pre><code data-trim data-noescape class="no-highlight">
<span class="blue">$ git status</span>
…
Untracked files:
(use "git add <file>..." to include in what will be committed)
<u>vendor/</u>
…
</code></pre>
<pre><code data-trim data-noescape class="no-highlight">
<span class="blue">$ </span><b class="right">git config --global status.showUntrackedFiles all</b>
<span class="blue">$ git status</span>
…
Untracked files:
(use "git add <file>..." to include in what will be committed)
<u> vendor/scripts/bootstrap.min.js
vendor/scripts/jquery.min.js
vendor/scripts/underscore.js</u>
…
</code></pre>
</section> -->
<!-- <section id="commits-diff-w" data-duration="15s">
<h2>Dépolluer le diff</h2>
<p>Les whitespaces, le plus souvent, OSEF.</p>
<pre><code data-trim data-noescape class="no-highlight">
<span class="blue">$ git diff</span>
…
<!doctype html>
<span class="red">-<html></span>
<span class="green">+<html lang="fr"></span>
<head>
<span class="red">- <meta charset="utf-8">
- <title>Git ProTips</title></span>
<span class="green">+ <u> </u><meta charset="utf-8">
+ <u> </u><title>Git <u> </u>ProTips</title></span>
…
<span class="blue">$ git diff <u>-w</u></span>
…
<!doctype html>
<span class="red">-<html></span>
<span class="green">+<html lang="fr"></span>
<head>
…
</code></pre>
</section> -->
<!-- <section id="commits-add-patch" data-duration="1m30s">
<h2>Fragments de fichiers</h2>
<p>Qui a dit qu’on devait <span lang="en">stager</span> tout le fichier d’un coup ?</p>
<pre><code data-trim data-noescape class="no-highlight">
<span class="blue">$ git add <u>-p</u> index.html</span>
…
<!doctype html>
<span class="red">-<html></span>
<span class="green">+<html lang="fr"></span>
<head>
…
<span class="blue">Stage this hunk [y,n,q,a,d,/,j,J,g,e,?]?</span> <u>y</u>
…
<h1>Git ProTips</h1>
<span class="green">+ <footer>© 2014 Ma Boîte</footer></span>
…
<span class="blue">Stage this hunk [y,n,q,a,d,/,K,g,e,?]? </span> <u>n</u>
</code></pre>
<p>Juste <strong>critique</strong> parce que dans la vraie vie, on a toujours 2–3 sujets distincts en cours dans un même fichier…</p>
</section> -->
<section id="commits-unstage" data-duration="15s">
<h2>Unstage</h2>
<p>Remove a file from the <span lang="en">stage</span> : <code>git reset</code>.</p>
<pre><code data-trim data-noescape class="bash">
<span class="blue">$ git <u>reset index.html</u></span>
Unstaged changes after reset:
M index.html
</code></pre>
<p>Cancel the <span lang="en">stage</span> :</p>
<pre><code data-trim data-noescape class="bash">
<span class="blue">$ git <u>reset</u></span>
Unstaged changes after reset:
M index.html
</code></pre>
</section>
<!-- <section id="commits-reset-patch" data-duration="30s">
<h2>Unstage partiel</h2>
<p>C’est comme pour l’ajout : on peut n’<span lang="en">unstager</span> que certains fragments.</p>
<pre><code data-trim data-noescape class="no-highlight">
<span class="blue">$ git <u>reset -p index.html</u></span>
…
…
<!doctype html>
<span class="red">-<html></span>
<span class="green">+<html lang="fr"></span>
<head>
…
<span class="blue"><u>Unstage</u> this hunk [y,n,q,a,d,/,j,J,g,e,?]?</span> <u>n</u>
…
<h1>Git ProTips</h1>
<span class="green">+ <footer>© 2014 Ma Boîte</footer></span>
…
<span class="blue"><u>Unstage</u> this hunk [y,n,q,a,d,/,K,g,e,?]? </span> <u>y</u>
</code></pre>
</section> -->
<!-- <section id="commits-show" data-duration="45s">
<h2>Visualiser un commit, un snapshot</h2>
<p><code>git show [object]</code> permet d’afficher au mieux un commit (par défaut <code>HEAD</code>), une arbo, un snapshot (blob)…</p>
<pre><code data-trim data-noescape class="no-highlight">
<span class="blue">$ <u>git show</u></span> <span class="comment"># ou explicitement : git show HEAD</span>
<span class="yellow">commit 8a5a383</span>
Author: Christophe Porteneuve <tdd@tddsworld.com>
Date: Sun Oct 26 15:04:17 2014 +0100
Premier index
<span class"yellow">diff --git a/index.html b/index.html</span>
…
</code></pre>
<p>Le contenu de <code>app/initialize.js</code> en branche <code>legacy</code> ?</p>
<pre><code data-trim data-noescape class="bash">
<span class="blue">$ git show <u>legacy:app/initialize.js</u></span>
'use strict';
…
</code></pre>
</section>
-->
<section>
<h1>Thank you !</h1>
<h3>May the Git be with you</h3>
<br>
<p>Alexis Fouche</p>
<p><a href="http://git.alfo.io">http://git.alfo.io</a></p>
</section>
</section>
</div>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.js"></script>
<script>
// Full list of configuration options available here:
// https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: true,
center: true,
width: 980,
theme: Reveal.getQueryHash().theme, // available themes are in /css/theme
transition: Reveal.getQueryHash().transition || 'linear', // default/cube/page/concave/zoom/linear/fade/none
// Parallax scrolling
// parallaxBackgroundImage: 'https://s3.amazonaws.com/hakim-static/reveal-js/reveal-parallax-1.jpg',
// parallaxBackgroundSize: '2100px 900px',
// Optional libraries used to extend on reveal.js
dependencies: [
{ src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'plugin/zoom-js/zoom.js', async: true, condition: function() { return !!document.body.classList; } },
{ src: 'plugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } },
{ src: 'plugin/time-tracker/time-tracker.js', async: true }
]
});
</script>
</body>
</html>