forked from hakimel/reveal.js
-
Notifications
You must be signed in to change notification settings - Fork 4
/
git_svn101.html
executable file
·688 lines (677 loc) · 27.4 KB
/
git_svn101.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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>reveal.js - Git</title>
<meta name="description" content="A framework for easily creating beautiful presentations using HTML">
<meta name="author" content="Hakim El Hattab">
<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.min.css">
<link rel="stylesheet" href="css/theme/default.css" id="theme">
<!-- For syntax highlighting -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<!-- If the query includes 'print-pdf', include the PDF print sheet -->
<script>
if( window.location.search.match( /print-pdf/gi ) ) {
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = 'css/print/pdf.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
}
</script>
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<section>
<h1>GIT 101</h1>
</section>
<section>
<h2>Why Version Control System ?</h2>
<p>Collaboration Issue !!</p>
<p><img width="400" height="400" src="img/collaboration1.jpg" alt="Down arrow"></p>
<p><font size="4px">http://carriebjackson.files.wordpress.com/2012/09/collaboration1.jpg</font></p>
</section>
<section>
<h2>Version Control System</h2>
<ul>
<li class="fragment">Local</li>
<li class="fragment">Centralize</li>
<li class="fragment">Distributed</li>
</ul>
</section>
<section>
<h2>Local</h2>
<p>Copy file and folder</p>
<p><img width="400" height="400" src="img/local-vcs.png"></p>
<p><font size="4px">http://git-scm.com/figures/18333fig0101-tn.png</font></p>
</section>
<section>
<h2>Centralize</h2>
<p>CVS, SVN</p>
<p><img width="500" height="400" src="img/central-vcs.png"></p>
<p><font size="4px">http://git-scm.com/figures/18333fig0102-tn.png</font></p>
</section>
<section>
<h2>Distributed</h2>
<p>Git, Mercurial HG, Bazaar</p>
<p><img width="500" height="400" src="img/distribute-vcs.png"></p>
<p><font size="4px">http://git-scm.com/figures/18333fig0103-tn.png</font></p>
</section>
<section>
<h2>Why SVN ?</h2>
<ul>
<li class="fragment">Powerful with command line interface</li>
<li class="fragment">Free / Open source</li>
<li class="fragment">Faster</li>
<li class="fragment">DB based not file based</li>
<li class="fragment">Customized attributes to be attached to files</li>
<li class="fragment">Automatically handles all file types without instructions</li>
<li class="fragment">Support Folder / File rename & copies maintaining the history</li>
</ul>
</section>
<section>
<h2>SVN Dataflow</h2>
<p><img width="400" height="400" src="img/svn-workflow.png" alt="Down arrow"></p>
<p><font size="4px">http://chadthompson.me/wp-content/uploads/2012/12/svn-workflow.png</font></p>
</section>
<section>
<h2>SVN Repository</h2>
<ul>
<li class="fragment">branches - Experimental</li>
<li class="fragment">tags - Specific version</li>
<li class="fragment">trunk - Main copy</li>
</ul>
</section>
<section>
<h2>SVN in Action</h2>
<ul>
<li class="fragment">svn checkout [repo_url]</li>
<li class="fragment">svn add [a file/directory]</li>
<li class="fragment">svn delete</li>
<li class="fragment">svn commit</li>
<li class="fragment">svn update</li>
<li class="fragment">svn mv(move)</li>
<li class="fragment">svn help</li>
<li class="fragment">svn diff</li>
<li class="fragment">svn revert</li>
<li class="fragment">svn list</li>
</ul>
</section>
<section>
<h2>Why GIT ?</h2>
<ul>
<li class="fragment">Distributed - no single of failure</li>
<li class="fragment">Speed - work on local</li>
<li class="fragment">Simple - less config</li>
<li class="fragment">Non-linear development</li>
<li class="fragment">Easy Merging</li>
<li class="fragment">No file locks</li>
</ul>
</section>
<section>
<h2>Git Dataflow</h2>
<p><img width="300" height="300" src="img/Git_data_flow_simplified.svg.png"></p>
<p><font size="4px">http://upload.wikimedia.org/wikipedia/commons/thumb/4/44/Git_data_flow_simplified.svg/300px-Git_data_flow_simplified.svg.png</font></p>
</section>
<section data-markdown>
## Start From Scratch
<pre><code contenteditable style="margin-top: 20px;">
arm$ git init
Initialized empty Git repository in /workspace/git101/.git/
</code></pre>
</section>
<section data-markdown>
## Existing Repo
<pre><code contenteditable style="margin-top: 20px;">
arm$ git clone https://github.com/armeo/git101.git <location>
</code></pre>
</section>
<section data-markdown>
## Git Help
<pre><code contenteditable style="margin-top: 20px;">
arm$ git help
</code></pre>
</section>
<section data-markdown>
## Git Setting
<pre><code contenteditable style="margin-top: 20px;">
arm$ git config --global user.name "Arm"
arm$ git config --global user.email "[email protected]"
arm$ git config --global color.ui auto
arm$ git config --global alias.st status
</code></pre>
</section>
<section data-markdown>
## Committing a change
<pre><code contenteditable style="margin-top: 20px;">
arm$ echo "Initial README" > README.md
arm$ git add README.md
arm$ git commit -m "Add README"
[master (root-commit) d369bc8] Add README
1 file changed, 1 insertion(+)
create mode 100644 README.md
</code></pre>
</section>
<section data-markdown>
## What Happened
<pre><code contenteditable style="margin-top: 20px;">
arm$ git log
commit d369bc8ccc7e86de1e8c99df8c142674380dcdcd
Author: Arm <[email protected]>
Date: Thu Mar 21 22:19:37 2013 +0700
Add README
</code></pre>
</section>
<section>
<h2>The Staging area</h2>
<p><img width="350" height="200" src="img/git-staging-area.png"></p>
<p><font size="4px">http://codingdomain.com/git/partial-commits/git-staging-area.png</font></p>
</section>
<section>
<h2>Workflow</h2>
<ul>
<li class="fragment"> Code</li>
<li class="fragment"> Stage your changes (git add)</li>
<li class="fragment"> Review your work (git status, git diff)</li>
<li class="fragment"> Commit (locally) (git commit)</li>
<li class="fragment"> Repeat</li>
</ul>
</section>
<section data-markdown>
## Un-Stages Change
<pre><code contenteditable style="margin-top: 20px;">
arm$ echo "I'm updateing README" > README.md
arm$ git status
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: README.md
#
no changes added to commit (use "git add" and/or "git commit -a")
</code></pre>
</section>
<section data-markdown>
## Stages Change
<pre><code contenteditable style="margin-top: 20px;">
arm$ git add .
arm$ git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: README.md
#
</code></pre>
</section>
<section data-markdown>
## Reset
<pre><code contenteditable style="margin-top: 20px;">
arm$ git reset
Unstaged changes after reset:
M README.md
arm$ git status
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: README.md
#
no changes added to commit (use "git add" and/or "git commit -a")
</code></pre>
</section>
<section data-markdown>
## Hard Reset
<pre><code contenteditable style="margin-top: 20px;">
arm$ git reset --hard HEAD
HEAD is now at d369bc8 Add README
</code></pre>
</section>
<section>
<h2>Why Branch ?</h2>
<ul>
<li class="fragment"> Safely experiment with new ideas</li>
<li class="fragment"> Agility</li>
<li class="fragment"> Git makes branching easy</li>
<li class="fragment"> Git makes mergeing (usually...) very easy</li>
</ul>
</section>
<section>
<h2>Branch and Merge</h2>
<p><img width="440" height="240" src="img/branch-tn.png"></p>
<p><font size="4px">http://git-scm.com/figures/18333fig0317-tn.png</font></p>
</section>
<section data-markdown>
## How do we do it ?
<pre><code contenteditable style="margin-top: 20px;">
arm$ git checkout -b new_feature
Switched to a new branch 'new_feature'
arm$ git branch
master
* new_feature
arm$ git checkout master
Switched to branch 'master'
arm$ git branch
* master
new_feature
arm$ git branch -d new_feature
Deleted branch new_feature (was d369bc8).
arm$ git branch
* master
</code></pre>
</section>
<section data-markdown>
## What about merge ?
<pre><code contenteditable style="margin-top: 20px;">
arm$ git checkout -b update_readme
arm$ git branch
master
* update_readme
arm$ vi README.md
arm$ git add .
arm$ git commit -m "update README"
[update_readme 78fb5b8] update README
1 file changed, 2 insertions(+)
arm$ git status
# On branch update_readme
nothing to commit (working directory clean)
arm$ git checkout master
Switched to branch 'master'
arm$ git merge update_readme
Updating d369bc8..78fb5b8
Fast-forward
README.md | 2 ++
1 file changed, 2 insertions(+)
arm$ git status
# On branch master
nothing to commit (working directory clean)
</code></pre>
</section>
<section data-markdown>
## Conflict !!
<pre><code contenteditable style="margin-top: 20px;">
Try ...
</code></pre>
</section>
<section data-markdown>
## Sharing your work
<pre><code contenteditable style="margin-top: 20px;">
git remote add <remote_name> <remote_url>
git push <remote_name> <branch_name>
git pull <remote_name> <branch_name>
git fetch <remote_name> <branch_name>
</code></pre>
</section>
<section data-markdown>
## Viewing Changes
<pre><code contenteditable style="margin-top: 20px;">
git log # show a log of changes
git status # see which file you changed
git diff # view uncommitted changes in the working copy
git show <commitid> # show one commit
</code></pre>
</section>
<section data-markdown>
## Undoing local changes
<pre><code contenteditable style="margin-top: 20px;">
git checkout <filename> #restore original, throw local changes away
git checkout -f # throw all local changes away
git reset --hard # the same
git rm <filename> # remove file
</code></pre>
</section>
<section>
<h2>Scenario based: Problem & Solutions</h2>
</section>
<section>
<h2>1. How to create a local repo ?</h2>
</section>
<section>
<pre><code contenteditable>git init</code></pre>
</section>
<section>
<h2>2. How to clone a remote repo ?</h2>
</section>
<section>
<pre><code contenteditable>git clone [repo_url]</code></pre>
</section>
<section>
<h2>3. How to see history ?</h2>
</section>
<section>
<pre><code contenteditable>git log --oneline --graph</code></pre>
</section>
<section>
<h2>4. How to used alias ?</h2>
</section>
<section>
<pre><code contenteditable>git config --global alias.lg "log --graph --decorate --oneline --abbrev-commit"</code></pre>
</section>
<section>
<p><img width="500" height="400" src="img/1.png"></p>
</section>
<section>
<h2>5. How to make a commit ?</h2>
</section>
<section>
<pre><code contenteditable>
git status
echo 'hello world' >> file1.txt
git status
git add file1.txt
git status
git commit -m "my first commit"
</code></pre>
</section>
<section>
<p><img width="600" height="400" src="img/2.png"></p>
<p>svn add != git add</p>
</section>
<section>
<p><img width="800" height="500" src="img/3.png"></p>
</section>
<section>
<h2>6. Git Diff</h2>
</section>
<section>
<pre><code contenteditable>
echo 'test git diff' >> file1.txt
git status
git diff
git add file1.txt
git status
# change to be committed # (use "git rm --cached [file]" to unstage)
</code></pre>
</section>
<section>
<p><img width="600" height="500" src="img/4.png"></p>
</section>
<section>
<h2>7. Index is a SNAPSHOT !!</h2>
</section>
<section>
<pre><code contenteditable>
echo 'forgot something' >> file1.txt
git status
git diff
git commit -am "add something"
</code></pre>
</section>
<section>
<p><img width="800" height="400" src="img/5.png"></p>
</section>
<section>
<h2>8. How to create a new branch ?</h2>
</section>
<section>
<pre><code contenteditable>
git branch feature1
git branch
git checkout feature1
git branch
git lg
</code></pre>
</section>
<section>
<p><img width="500" height="400" src="img/6.png"></p>
</section>
<section>
<p><img width="600" height="550" src="img/7.png"></p>
</section>
<section>
<p><img width="620" height="550" src="img/8.png"></p>
</section>
<section>
<h2>9. How to create a new branch and switch to it ?</h2>
</section>
<section>
<pre><code contenteditable>
git checkout -b feature2
git branch
</code></pre>
</section>
<section>
<h2>10. How to create a new branch from a commit point ?</h2>
<pre><code contenteditable>
git checkout -b feature3 HEAD~1
git branch
git lg --all
</code></pre>
</section>
<section>
<h2>11. Makes 2 commit to feature2 branch</h2>
</section>
<section>
<pre><code contenteditable>
git checkout feature2
echo 'feature 2.1' >> feature2.txt
git add feature2.txt
git commit -m "completed task 2.1"
echo 'feature 2.2' >> feature2.txt
git commit -am "complete task 2.2"
git lg
</code></pre>
</section>
<section>
<p><img width="790" height="600" src="img/9.png"></p>
</section>
<section>
<h2>12. How to merge a branch ?</h2>
</section>
<section>
<pre><code contenteditable>
git checkout master
git merge feature2
git lg
</code></pre>
</section>
<section>
<p><img width="820" height="540" src="img/10.png"></p>
</section>
<section>
<h2>13. Switch back to feature3 branch and create 1 new commit !!</h2>
</section>
<section>
<pre><code contenteditable>
git checkout feature3
echo 'feature3' >> feature3.txt
git add feature3.txt
git commit -m "complete feature3"
git lg
</code></pre>
</section>
<section>
<p><img width="840" height="600" src="img/11.png"></p>
</section>
<section>
<h2>14. Switch back to master branch and merge feature3 branch !!</h2>
</section>
<section>
<pre><code contenteditable>
git checkout master
git merge feature3
git lg
</code></pre>
</section>
<section>
<p><img width="930" height="570" src="img/12.png"></p>
</section>
<section>
<h2>15. How to reset a branch ?</h2>
</section>
<section>
<pre><code contenteditable>
git checkout master
git reset --hard feature2
git lg
</code></pre>
</section>
<section>
<p><img width="740" height="600" src="img/13.png"></p>
</section>
<section>
<h2>16. How to delete a branch ?</h2>
</section>
<section>
<pre><code contenteditable>
git checkout master
git branch -D feature2
git branch
git lg
</code></pre>
</section>
<section>
<p><img width="740" height="600" src="img/14.png"></p>
</section>
<section>
<h2>17. How to rebase a branch ?</h2>
</section>
<section>
<pre><code contenteditable>
git checkout feature3
git rebase master
git branch
git lg
</code></pre>
</section>
<section>
<p><img width="930" height="600" src="img/15.png"></p>
</section>
<section>
<p><img width="890" height="470" src="img/16.png"></p>
</section>
<section>
<p><img width="880" height="460" src="img/17.png"></p>
</section>
<section>
<h2>18. How to see remote details ?</h2>
</section>
<section>
<pre><code contenteditable>
git remote -v
git remote show origin
</code></pre>
</section>
<section>
<h2>19. How to see tracking remote branches ?</h2>
</section>
<section>
<pre><code contenteditable>
git branch -r
git branch -a
</code></pre>
</section>
<section>
<h2>20. How to push changes to a branch ?</h2>
</section>
<section>
<pre><code contenteditable>git push origin master</code></pre>
</section>
<section>
<h2>21. How to pull from remote ? </h2>
</section>
<section>
<pre><code contenteditable>
git pull origin master
# git pull == git fetch; git merge origin/master #
# git pull --rebase == git fetch; git rebase origin/master #
</code></pre>
</section>
<section>
<h2>22. How to stash changes ?</h2>
</section>
<section>
<pre><code contenteditable>
git reset --hard HEAD~1
echo 'test stash' >> feature2.txt
git status
git pull origin master
git stash
git status
git pull origin master
git stash pop
</code></pre>
</section>
<section>
<h2>23. How to create a tag ?</h2>
</section>
<section>
<pre><code contenteditable>
git tag v1.0
git tag v1.1 [commit]
git push origin v1.0
</code></pre>
</section>
<section>
<h2>24. How to delete a local branch ?</h2>
</section>
<section>
<pre><code contenteditable>git branch -D feature2</code></pre>
</section>
<section>
<h2>25. How to delete a remote branch ?</h2>
</section>
<section>
<pre><code contenteditable>git push origin :feature2</code></pre>
</section>
<section>
<h2>26. How to remove deleted tracking branch ?</h2>
</section>
<section>
<pre><code contenteditable>
git branch -a
git fetch
git prune
git fetch -p
</code></pre>
</section>
<section>
<h2>27. How to revert a public commit ?</h2>
</section>
<section>
<pre><code contenteditable>git revert #commit</code></pre>
</section>
<section>
<h1>THE END</h1>
<h3>" ยิ่งให้ ยิ่งได้ ยิ่งเรียนรู้ "</h3>
</section>
</div>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.min.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,
theme: Reveal.getQueryHash().theme, // available themes are in /css/theme
transition: Reveal.getQueryHash().transition || 'default', // 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; } }
]
});
</script>
</body>
</html>