-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.html
More file actions
879 lines (797 loc) · 37.6 KB
/
index.html
File metadata and controls
879 lines (797 loc) · 37.6 KB
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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Git</title>
<meta name="description" content="A Lecture about Version Control, Git and Github.">
<meta name="author" content="Chris Morgan">
<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/sky.css" id="theme">
<link rel="stylesheet" href="css/custom.css">
<!-- 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">
<div class="slides">
<section>
<h3>SESA presents</h3>
<h1>Git & GitHub</h1>
<h4>An Introduction to Version Control</h4>
</section>
<section>
<h2>SESA</h2>
<div class="stick-left">
<h4>Community</h4>
<small>
<ul>
<li>We're a group of past and present Software Engineering students.</li>
<li>Form friendships with students in other year levels.</li>
<li>Make some great industry contacts.</li>
<br>
</ul>
</small>
<h4>Social</h4>
<small>
<ul>
<li>LAN parties, cardboard evenings, movie nights and post exam commiseration.</li>
<li>Guest lectures from leaders in their field of expertise.</li>
<li>Upcoming Games Day on the 3rd of September! </li>
</ul>
</small>
</div>
<aside class="notes">
Talk about the awesome LAN we had at work and cardboard nights in Leech.
<br>Free Pizza.
<br>$1 joining fee.
<br>Industry evening
<br>
</aside>
</section>
<section>
<section>
<h4>Chapter 1</h4>
<h3>Version Control Systems</h3>
<aside class="notes">
Ask if class knows what it is.
</aside>
</section>
<section>
<h3>Why do we need Version Control?</h3>
<ul class="fragment roll-in">
<li>Safety</li>
<li>Collaboration</li>
<li>Maintenance</li>
</ul>
<aside class="notes">
Ask class why they think it's needed.
<br>
</aside>
</section>
<section>
<h2>Safety</h2>
<p><small>If we make a mistake in our code and break everything, how do we fix it?</small></p>
<ul>
<li>
Copy and past folders to track versions?
<br>
<small>
This is horrible! Imagine the hundreds of folders to manage.<br>
It only leads to confusion of where bugs were introduced and a bloated project folder.<br>
What if you couldn't find where you went wrong and had to redo half of the project?
</small>
</li>
<li>
Instead use a Version Control System
<br>
<small>
Changes made to files are stored as differences between versions.<br>
When you've made a change to a file(s), save the difference it into the VCS.
</small>
</li>
</ul>
<aside class="notes">
Ever broken something and not known how to fix it?<br> If you use git you won't have to worry about
it.
</aside>
</section>
<section>
<h2>Collaboration</h2>
<p><small>How do multiple people work on a project simultaneously?</small></p>
<ul>
<li>
Pass files around on a USB drive?
<br>
<small>
No. This is the old way of sharing progress.<br>
Comparing two files and finding the difference between the two is very tedius and time consuming.<br>
</small>
</li>
<li>
Instead use a Version Control System
<br>
<small>
Changes made to files are stored as differences between versions.<br>
When you've made a change to code, save the difference it into the VCS.
</small>
</li>
</ul>
<aside class="notes">
This is how it used to be done, except on floppy drives.
<br>Refer to GitHub and explain that we'll be using it later.
</aside>
</section>
<section>
<h2>Maintenance</h2>
<p><small>How do we support old versions of our code that have been deployed?</small></p>
<ul>
<li>
Fix current code set and re-deploy.
<br>
<small>
More than likely, the programme has changed significantly and is now incompatible with the customer's system.<br>
The 'bug' could have been built into a new feature or is a dependency in something new.
</small>
</li>
<li>
Version control makes this a lot simpler.
<small>
With version control you could find the bug, go back and fix it then deploy the changes to the customer.<br>
</small>
</li>
</ul>
<aside class="notes">
Again, explain that examples will come in the next chapter.
</aside>
</section>
</section>
<section>
<section>
<h4>Chapter 2</h4>
<h3>Git</h3>
<aside class="notes">
</aside>
</section>
<section>
<h3>What is Git?</h3>
<p><small>Git is a very popular distributed version control system that you'll be using during this course.</small></p>
<ul>
<li>
What is a repository?
<br>
<small>A repo is your project code and history of changes that were made.</small>
</li>
<li>
What goes in a repo?
<br>
<small>
<ul>
<li>Code</li>
<li>Documentation</li>
<li>The history of changes (this is managed is managed by git)</li>
</ul>
</small>
</li>
<li>
What doesn't go in a repo?
<br>
<small>
<ul>
<li>Compiled files (.exe .class .pyc)</li>
<li>Project setting files</li>
</ul>
</small>
</li>
</ul>
<aside class="notes">
git - the stupid content tracker
<br>Why is it called git?
<br>Torvalds said: "I'm an egotistical bastard, and I name all my projects after myself. First 'Linux',
now 'git'."
</aside>
</section>
<section>
<h3><code class='normalcase'>> git init</code></h3>
<ul>
<li>Creates an empty repo</li>
<li>All history and settings are stored in the .git folder</li>
</ul>
<aside class="notes">
Time to start the live demo.
</aside>
</section>
<section>
<h3><code class='normalcase'>> git status</code></h3>
<ul>
<li>
Show us the status of the repo
<br>
<small>
The branch we're on<br>
The files have changed<br>
The files are staged for commit
</small>
</li>
<li>
Git isn't automatic
<br>
<small>
We need to tell it what files to track, stage and commit.
</small>
</li>
</ul>
<aside class="notes">
</aside>
</section>
<section>
<h3><code class='normalcase'>> git add <file> [...]</code></h3>
<ul>
<li>
Adds a file to be tracked by git
<br>
<small>
Simply adding a file to the repository does not mean its changes are being tracked by git.<br>
</small>
</li>
<li>
Adding all the files in a new project can be tedious
<br>
<small>
Fortunately, there is a shortcut.<br>
</small>
</li>
<li>
<code>> git add .</code>
<br>
<small>
This adds all files from the current working directory downwards.<br>
If run in the root directory of the project, it will add all files.
</small>
</li>
</ul>
<aside class="notes">
<code>git add --all</code> is another way to add all files.
</aside>
</section>
<section>
<h3><code class='normalcase'>> git commit</code></h3>
<ul>
<li>
Committing puts the staged files into the repository
<br>
<small>
If files have changed, a diff is created reflecting the change.
</small>
</li>
<li>
Committing is like taking a snapshot of the code
<br>
<small>
In the Version Control section, I discussed creating new folders to keep track of versions. <br>
Committing is more or less the equivalent, but a much cleaner solution.
</small>
</li>
<li>
The commit message is used to document changes
<br>
<small>
<code>git commit -m 'Make some really cool changes'</code><br>
The option <code>-m 'msg'</code> is a shortcut to add all tracked files and write a commit message in line before committing.
</small>
</li>
</ul>
<aside class="notes">
Commit often and write detailed messages, allows easier fault finding and collaboration.
</aside>
</section>
<section>
<h3 class='normalcase'>The <code class='normalcase'>.gitignore </code> file</h3>
<ul>
<li>
You don't want all files to be tracked in your repository
<br>
<small>
Remember those binary files? They shouldn't be tracked.<br>
Local config for the project, IDEs and OS specific files should also be excluded.
</small>
</li>
<li>
<a href='https://gitignore.io'>gitignore.io</a>
<br>
<small>
This is a great resource to create a .gitignore file for your project.
</small>
</li>
</ul>
<aside class="notes">
Talk about 200MB zip file fiasco at work.
</aside>
</section>
<section>
<h3><code class='normalcase'>> git log</code></h3>
<ul>
<li>
Shows the history of the repo
<br>
<small>
This is an easy way to see what changes have been made recently.
</small>
</li>
<li>
Each commit in the log contains:
<br>
<small>
- Who wrote it<br>
- When they committed it<br>
- A hash to uniquely identify it<br>
- The commit message
</small>
</li>
</ul>
<aside class="notes">
</aside>
</section>
<section>
<h3><code class='normalcase'>> git branch <branchname></code></h3>
<ul>
<li>
Branches are different versions of a repo
<br>
<small>
By default a repo is on the <code>master</code> branch, this ideally should be the stable build of the project.<br>
When we're developing something, we're going to break it. Having a safe space to do this is what branches provide.<br>
</small>
</li>
<li>
<code>git branch feature/hello-nasser</code>
<br>
<small>
This creates a branch identical to the current branch for us to experiment on.
</small>
</li>
</ul>
<aside class="notes">
</aside>
</section>
<section>
<h3><code class='normalcase'>> git checkout <branch|commit></code></h3>
<ul>
<li>
Allows us to change branches at any time
<br>
<small>
<code>git checkout feature/hello-nasser</code><br>
This takes us to the <code>feature/hello-nasser</code> branch so we can make some changes without affecting others.
</small>
</li>
<li>
Shortcut to create a branch and check it out
<br>
<small>
<code>git checkout -b <branch></code><br>
</small>
</li>
<li>
Also allows us to go to any point in the history of the repo
<br>
<small>
Looking at the files after checking out a previous commit shows that we've gone back in time.
</small>
</li>
</ul>
<aside class="notes">
</aside>
</section>
<section>
<h3><code class='normalcase'>> git merge <branchname></code></h3>
<ul>
<li>Merges changes from one branch into another
<br>
<small>
Once we've finished with out changes to the <code>feature/hello-nasser</code> branch, we'll want to propagate those changes to the main branch.<br>
To do this, we checkout the <code>master</code> branch then merge changes from the <code>feature/hello-nasser</code> branch.<br>
<code>git checkout master</code><br>
<code>git merge feature/hello-nasser</code>
</small>
</li>
<li>
Merge Conflicts
<br>
<small>
If two people change the same lines of one file, the merge algorithm <code>git</code> uses isn't smart enough to tell which branch contains the correct changes.
The responsibility falls to you to sort out the conflict.
</small>
</li>
</ul>
<aside class="notes">
</aside>
</section>
</section>
<section>
<section>
<h4>Chapter 3</h4>
<h3>GitHub</h3>
<aside class="notes">
</aside>
</section>
<section>
<h3>What is Github?</h3>
<small>
<p>GitHub is a web app that hosts your repos remotely.</p>
<p>It has a great web interface to see commits and statistics.</p>
</small>
<div>
<p>It allows you to:</p>
<small>
<ul>
<li>Backup your code</li>
<li>Collaborate with others easily</li>
<li>Have a 'true' source of code</li>
</ul>
</small>
</div>
<aside class="notes">
</aside>
</section>
<section>
<h3>Centralised vs. Distributed VCS</h3>
<ul>
<li>Centralised
<br>
<small>
No files need to be kept on the programmer's HDD<br>
All changes made need to be committed to the central repo
</small>
</li>
<li>
Distributed
<br>
<small>
Each person working on the code has a complete clone of the repo and contains all metadata.<br>
No dependence on a single source, but often there is a 'origin' for easy collaboration.<br>
Git is a distributed and GitHub is often used as the 'true source' remote repo.
</small>
</li>
</ul>
<aside class="notes">
</aside>
</section>
<section>
<h3>Creating a Repo</h3>
<ul>
<li>
Name
<br>
<small>
<ul>
<li>Identifier on GitHub</li>
<li>Used as default directory name when cloning the repo.</li>
</ul>
</small>
</li>
<li>
Public/Private
<br>
<small>
<ul>
<li>Public means that other GitHub users can browse and, download and fork your repo.</li>
<li>This encourages open source software development!</li>
<li>Public repos are hosted for free :D</li>
<li>Private repos are invisible to everyone except owner and collaborations.</li>
<li>You can invite people to collaborate on your project.</li>
<li>Student accounts have unlimited free private repos!</li>
<li>Use these for assignments and personal projects. Make them public after marks are released.</li>
<li>Having your code public on github is a great way to show potential employers your skills.</li>
</ul>
</small>
</li>
</ul>
<aside class="notes">
</aside>
</section>
<section>
<h3>Connecting to GitHub</h3>
<ul>
<li>
Add the GitHub repo as the 'origin' remote repo
<br>
<small>
<ul>
<li><code>git remote add origin git@github.com:drpotato/git-lecture.git</code></li>
<li>You can have any number of remotes. Origin is usually the 'upstream' or 'source of truth'</li>
<li>Remotes can be any type of url, even a local file system url</li>
</ul>
</small>
</li>
<li>
Get your code on GitHub
<br>
<small>
<ul>
<li><code>git push <remote> <branch></code></li>
<li>add <code>-u</code> option to set branch as upstream.</li>
</ul>
</small>
</li>
</ul>
<aside class="notes">
</aside>
</section>
<section>
<h3>Pull Requests</h3>
<small><p>When we've made some changes to the code, but don't have sufficient permission to write data, you'll need to make a pull request to the owner of the repo.</p></small>
<ul>
<li>
What is it?
<br>
<small>
<ul>
<li>Sends a request to the owner to pull (merge) the changes you made into their repo.</li>
<li>This allows collaborators to view and discuss changes in a branch as they are made.</li>
<li>Developers can comment on pull requests, even on specific lines of code.</li>
</ul>
</small>
</li>
</ul>
<aside class="notes">
</aside>
</section>
<section>
<h3>Issues</h3>
<ul>
<li>
What are issues?
<br>
<small>
<ul>
<li>Issues have the advantage over comments that they can be referenced in commit messages (you can also reference commit numbers eg “from b4ebbd4”)</li>
<li>e.g. <code>git commit -m 'Change countdown so it actually stops - fix #2'</code></li>
<li>A finished PR can be merged back into master. This will close all the issues that have been fixed in that branch and put the code back into master.</li>
</ul>
</small>
</li>
</ul>
<aside class="notes">
</aside>
</section>
<section>
<h3>Pulling Changes</h3>
<ul>
<li>
Changes made on a remote branch need to be fetched
<br>
<small>
<ul>
<li><code>git pull origin master</code></li>
<li>This fetches changes from the origin repo and merges them</li>
</ul>
</small>
</li>
<li>
<code>git pull</code> is actually a shortcut
<br>
<small>
<ul>
<li><code>git fetch <remote> <branch></code></li>
<li><code>git merge FETCH_HEAD</code></li>
<li>The pull shortcut is a lot easier, you'll probably never fetch manually.</li>
</ul>
</small>
</li>
</ul>
<aside class="notes">
Always pull changes before you start working on something. Talk about Tomy deleting all changes due to merge conflits.
</aside>
</section>
<section>
<h3>Cloning a Repo</h3>
<p><small>Downloads the repo to your local machine</small></p>
<ul>
<li>
<code>git clone [url] <directory></code>
<br>
<small>
<ul>
<li><code><directory></code> is optional, by default it's the repo at the end of <code>[url]</code></li>
<li>This fetches changes from the origin repo and merges them</li>
<li>Automatically uses <code>[url]</code> as <code>origin</code></li>
</ul>
</small>
</li>
</ul>
<aside class="notes">
</aside>
</section>
<section>
<h3>GitHub Tiki Tour</h3>
<ul>
<li>Adding Collaborators</li>
<li>Switching from public to private (and vice versa)</li>
<li>Deleting a repo</li>
<li>Wiki</li>
<li>Graphs</li>
<li>Browsing users and organisations</li>
</ul>
<aside class="notes">
</aside>
</section>
<section>
<h3>Undoing things</h3>
<p style='color:red'>This is dangerous stuff...</p>
<p style='color:green'>But fortune favours the bold!</p>
<small>
<ul>
<li><code>git reset [filename]</code><br>
Unstages the file.</li>
<li><code>git checkout [filename]</code><br>
Resets (permanently) a file to its state at the last commit.<br>
You can checkout any version of a file, read the docs to figure it out.</li>
<li><code>git commit --amend</code><br>
Includes <i>all changes since the last commit</i> into the last commit.<br>
Useful for when you forget to add a file.</li>
<li><code>git reset --hard HEAD</code><br>
Throws away (permanently) all changes since the last commit.</li>
</ul>
</small>
<aside class="notes">
</aside>
</section>
<section>
<h3>Seeing What Changed</h3>
<p>How do we see what has changed between versions?</p>
<small>
<ul>
<li>
<code>git diff</code><br>
Shows all changes to files since the last commit.
</li>
<li>
<code>git diff [filename]</code><br>
Shows all changes to a specific file since the last commit.
</li>
<li>
<code>git diff [commit]</code><br>
Shows all changes since the commit.
</li>
<li>
<code>git diff <branch>..<branch></code><br>
Shows the difference between two branches.
</li>
</ul>
</small>
<aside class="notes">
</aside>
</section>
</section>
<section>
<h3>Recap</h3>
<p><small>What you should take away</small></p>
<ul>
<li>The basics of working with Git
<br>
<small>
<ul>
<li><code>git init</code></li>
<li><code>git add .</code></li>
<li><code>git commit -m 'message'</code></li>
</ul>
</small>
</li>
<li>Looking at your repo
<br>
<small>
<ul>
<li><code>git status</code></li>
<li><code>git log</code></li>
<li><code>git diff</code></li>
</ul>
</small>
</li>
<li>
Avoid graphical clients!
<br>
<small>"Why?" you might ask:</small>
<br>
<small>
<ul>
<li>Easier to make mistakes</li>
<li>Great opportunity to learn command line tools</li>
<li>Often leads to messy repo with many untracked files</li>
</ul>
</small>
</li>
</ul>
<aside class="notes">
</aside>
</section>
<section>
<h3>Resources - Git</h3>
<ul>
<li><a href="http://git-scm.com/">Git Website</a> (where you get Git)</li>
<li><a href="http://git-scm.com/book">Git Book</a> (in depth)</li>
<li><a href="http://rogerdudler.github.io/git-guide/">Simple Guide</a></li>
<li><a href="http://gitimmersion.com/">Git Lab/Tutorial</a></li>
<li><a href="https://github.com/github/gitignore">Git Ignores</a> in all flavours</li>
<li><a href="https://github.com/ausesa">SESA GitHub Organisation</a></li>
<li><a href="http://sesa.org.nz">SESA Online</a></li>
<li><a href="http://www.facebook.com/groups/ausesa/">SESA on Facebook</a></li>
<li><a href="https://github.com/drpotato/git-lecture">Repo for this presentation</a></li>
</ul>
<aside class="notes">
</aside>
</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 || 'linear', // default/cube/page/concave/zoom/linear/fade/none
// 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>