forked from uw-loci/git-workshop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
689 lines (586 loc) · 21.1 KB
/
index.html
File metadata and controls
689 lines (586 loc) · 21.1 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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Git(Hub) workshop for LOCI</title>
<meta name="description" content="How to use Git and GitHub effectively">
<meta name="author" content="Johannes Koenig-Schindelin">
<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/moon.css" id="theme">
<!-- For syntax highlighting -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<!-- If the query includes 'print-pdf', use the PDF print sheet -->
<script>
document.write( '<link rel="stylesheet" href="css/print/' + ( window.location.search.match( /pdf/gi ) ? 'pdf' : 'paper' ) + '.css" type="text/css" media="print">' );
</script>
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
<style type="text/css">
.bold { color: #65a4e3; }
.reveal p { font-size: 40pt; }
.reveal section .icon { border: 0px; margin-bottom: 0; width: .9em; color: rgba(0, 0, 0, 1); }
.gallery img { border: 0px; width: auto; height: 5em; }
</style>
</head>
<body>
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<section>
<div style="float: left;"><img src="images/git.png" /> </div>
<h1>Using Git and GitHub</h1>
<h3>Like, effectively</h3>
<p>
<small>Johannes Koenig-Schindelin</small>
</p>
</section>
<section>
<section>
<h3>Prelude:<br />Why use a version control system?</h3>
<p style="font-family: Arial; font-size: 250pt; color: #8080ff">?</p>
</section>
<section>
<h3>Common scientific development workflow</h3>
<ul>
<li class="fragment">Email</li>
<li class="fragment">Record an ImageJ macro</li>
<li class="fragment">Meeting</li>
<li class="fragment">Where was I? Ah, yes: ImageJ macro</li>
<li class="fragment">Student needs something</li>
<li class="fragment">Change ImageJ macro</li>
<li class="fragment">It works no longer?</li>
<li class="fragment">WTF?</li>
<li class="fragment">???</li>
<li class="fragment">Boohooooo!</li>
</ul>
</section>
<section>
<h3>Common scientific development workflow, version II</h3>
<ul>
<li class="fragment">Coffee</li>
<li class="fragment">Make a change to Christopher's R script</li>
<li class="fragment">Test</li>
<li class="fragment">Make some more changes in the code</li>
<li class="fragment">Test</li>
<li class="fragment">Send the code to a collaborator</li>
<li class="fragment">It no longer works!</li>
<li class="fragment">WTF?</li>
<li class="fragment">???</li>
<li class="fragment">Boohooooo!</li>
</ul>
</section>
<section>
<h3>Less common scientific development workflow</h3>
<ul>
<li class="fragment">Dig up Michael's old Python script to stitch images</li>
<li class="fragment">It works, great!</li>
<li class="fragment">Somebody improved it, great!</li>
<li class="fragment">Michael actually improved other parts in the meantime!</li>
<li class="fragment">How to reconcile?</li>
<li class="fragment">???</li>
<li class="fragment">Boohooooo!</li>
</ul>
</section>
<section>
<h3>Most common development workflow</h3>
<ul>
<li class="fragment">Provide a macro to collaborator</li>
<li class="fragment">Six months later...</li>
<li class="fragment">Get mail saying: your code is broken</li>
<li class="fragment">Test verifies: is broken</li>
<li class="fragment">Used to work!</li>
<li class="fragment">Where is the working version?</li>
<li class="fragment">Aargh!</li>
<li class="fragment">Boohooooo!</li>
</ul>
</section>
</section>
<section>
<h1>The solution!</h1>
<ul>
<li class="fragment">Store "software revisions"</li>
<li class="fragment">A revision consists of:</li>
<ul>
<li class="fragment">A collection of files</li>
<li class="fragment">An author</li>
<li class="fragment">A date</li>
<li class="fragment">Usually based on a previous revision</li>
</ul>
<li class="fragment">Share those revisions via GitHub!</li>
</ul>
</section>
<section>
<h1>Overview</h1>
<ul>
<li class="fragment">Getting started</li>
<li class="fragment">Diffs</li>
<li class="fragment">Commits</li>
<li class="fragment">Commit history</li>
<li class="fragment">Merges</li>
<li class="fragment">Some theory</li>
<li class="fragment">Topic branches</li>
<li class="fragment">Bisecting</li>
<li class="fragment">Forking</li>
<li class="fragment">Pull Requests</li>
<li class="fragment">GitHub tricks</li>
</ul>
</section>
<section>
<section>
<h3>Getting started</h3>
<a href="http://git-scm.com/">http://git-scm.com/</a>
</section>
<section>
<h3>Configuring GitHub 1/3</h3>
<img src="images/github-mac-init.png" />
</section>
<section>
<h3>Configuring GitHub 2/3</h3>
<img src="images/github-mac-connect.png" />
</section>
<section>
<h3>Configuring GitHub 3/3</h3>
<img src="images/github-mac-config.png" />
</section>
<section>
<h3>(If you have Windows...)</h3>
<img src="images/github-windows-options.png" />
</section>
<section>
<h3>Cloning a repository 1/2</h3>
<img src="images/github-mac-clone.png" />
</section>
<section>
<h3>Cloning a repository</h3>
<img src="images/github-mac-clone2.png" />
</section>
<section>
<h3>Cloning on the command-line<br /><small>Christopher, wake up!</small></h3>
<pre>
<code lang="bash" data-trim contenteditable>
$ git clone https://github.com/tomancaklab/playground
Cloning into 'playground'...
remote: Reusing existing pack: 27, done.
remote: Total 27 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (27/27), done.
Checking connectivity... done.
</code>
</pre>
</section>
<section>
<h3>Accessing the working directory 1/2</h3>
<img src="images/github-mac-finder.png" />
</section>
<section>
<h3>Accessing the working directory 2/2</h3>
<img src="images/mac-finder.png" />
</section>
</section>
<section>
<section>
<h3>Diffs</h3>
<pre>
<code lang="diff" data-trim contenteditable>
diff --git a/anthem.txt b/anthem.txt
new file mode 100644
index 0000000..46ea613
--- /dev/null
+++ b/anthem.txt
@@ -0,0 +1,9 @@
+Lord, grant that Marshal Wade
+May, by thy mighty aid,
+Victory bring!
+
+May he sedition hush
+And, like a torrent, rush
+Rebellious Scots to crush.
+
+God save the King!
</code>
</pre>
</section>
<section>
<h3>Diffs, part II</h3>
<pre>
<code lang="diff" data-trim contenteditable>
diff --git a/anthem.txt b/anthem.txt
index 46ea613..d920528 100644
--- a/anthem.txt
+++ b/anthem.txt
@@ -7,3 +7,5 @@ And, like a torrent, rush
Rebellious Scots to crush.
God save the King!
+
+(melody: My country 'tis of thee)
</code>
</pre>
</section>
<section>
<h3>Making a new revision ("committing")</h3>
<img src="images/github-mac-changes.png" />
</section>
<section>
<h3>Committing on the command line</h3>
<pre>
<code lang="bash" data-trim contenteditable>
$ git status
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
hello.txt
nothing added to commit but untracked files present (use "git add" to track)
$ git add hello.txt
$ git commit
</code>
</pre>
</section>
<section>
<h3>Commit messages</h3>
<pre>
Short summary (50 characters or less)
More detailed explanatory text ("commit message body") after an empty
line, with additional information that cannot be inferred easily from
the diff, e.g. what bug this solves, who reported the issue.
Wrap it to 72 characters per line.
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.
Separate paragraphs with blank lines.
- Bullet points are okay, too
- Typically a hyphen or asterisk is used for the bullet, preceded by a
single space, with blank lines in between, but conventions vary here
- Use a hanging indent
</pre>
<div style="font-family: Arial;
font-size: 16pt; float: right;">Source: <a href="http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html">http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html</a></div>
</section>
<section>
<h3>A commit reflects a <i>revision</i></h3>
<p class="fragment">... that is, a <u>working</u> revision</p>
<p class="fragment">... i.e. not, <b>never <span style="color: red;">ever</span></b> <tt>"Many changes..."</tt>!!! Good example for a bad example: <small><a href="https://github.com/imagej/imagej/commit/ad125915d">https://github.com/imagej/imagej/commit/ad125915d</a></small></p>
<p class="fragment">... also avoid meaningless commit messages that help nobody, e.g. <small><a href="https://github.com/bigdataviewer/Descriptor_based_registration/commit/cdb21c1b">https://github.com/bigdataviewer/Descriptor_based_registration/commit/cdb21c1b</a></small></p>
</section>
</section>
<section>
<section>
<h3>Synchronizing</h3>
<img src="images/github-mac-sync.png" />
</section>
<section>
<h3>Synchronizing on the command line</h3>
<pre>
$ git pull
From https://github.com/tomancaklab/playground
* branch master -> FETCH_HEAD
Auto-merging README.md
CONFLICT (content): Merge conflict in README.md
Automatic merge failed; fix conflicts and then commit the result.
$ git status
On branch master
You have unmerged paths.
(fix conflicts and run "git commit")
Unmerged paths:
(use "git add <file>..." to mark resolution)
<span style="color: red;">both modified: README.md</span>
</pre>
</section>
<section>
<h3>Dealing with conflicts 1/4</h3>
<img src="images/github-mac-conflicts.png" />
</section>
<section>
<h3>Dealing with conflicts 2/4</h3>
<img src="images/github-mac-conflicts2.png" />
</section>
<section>
<h3>Dealing with conflicts 3/4</h3>
<img src="images/github-mac-resolving.png" />
</section>
<section>
<h3>A closer look at conflict markers</h3>
<pre>
# compress Prairie dataset to ZIP file
echo
echo "Compressing '$datasetFullName' to ZIP..."
if [ -e "$zipPath" ];
then
# ZIP file already exists; skip this dataset
echo "ZIP file already exists. Moving on..."
continue
fi
<span style="color: #ffc080;"><<<<<<< HEAD</span>
# make the directory
mkdir -p "${zipDir:-1}"
<span style="color: #8080ff;">=======</span>
mkdir -p "$zipDir"
<span style="color: #ff80ff;">>>>>>>> master</span>
(cd "$datasetBase" && zip -r9 "$zipPath" "$datasetName" > /dev/null)
# delete uncompressed Prairie dataset
echo
echo "Deleting '$datasetFullName'..."
</pre>
</section>
<section>
<h3>Dealing with conflicts 4/4</h3>
<img src="images/github-mac-resolved.png" />
</section>
<section>
<h3>Synchronizing (again...)</h3>
<img src="images/github-mac-push.png" />
</section>
<section>
<h3>Synchronizing (again...) on the command line</h3>
<pre>
$ git push
Username for 'https://github.com': bugsbunny
Password for 'https://dscho@github.com':
Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (5/5), 730 bytes | 0 bytes/s, done.
Total 5 (delta 1), reused 0 (delta 0)
To github.com:tomancaklab/playground
9388ba5..88bcfa0 HEAD -> master
</pre>
</section>
</section>
<section>
<section>
<h3>Looking at the history</h3>
<img src="images/github-mac-history.png" />
</section>
<section>
<h3>Another look at the history: gitk</h3>
<img src="images/gitk.png" />
</section>
<section>
<h3>"Yet another look, via the command-line: git log"</h3>
<ul>
<li><pre>git log</pre></li>
<li class="fragment"><pre>git log -p</pre></li>
<li class="fragment"><pre>git log origin/master</pre></li>
<li class="fragment"><pre>git log bin/</pre></li>
<li class="fragment"><pre>git log -SXmx</pre></li>
<li class="fragment"><pre>git log --author=Christopher</pre></li>
<li class="fragment"><pre>git log -3</pre></li>
<li class="fragment"><pre>git log HEAD^..HEAD^2</pre></li>
</ul>
</section>
</section>
<section>
<section>
<h3>Ignoring certain files 1/2</h3>
<img src="images/github-mac-ignore.png" />
</section>
<section>
<h3>Ignoring certain files 2/2</h3>
<img src="images/github-mac-gitignore.png" />
</section>
</section>
<section>
<section>
<h3>Some theory</h3>
</section>
<section>
<h3>"content-addressable database"</h3>
<table style="font-size: 20pt;" border=0>
<td><pre style="font-size: 20pt;">Mahna mahna<br />do dooh bee doo doo</pre></td>
<td class="fragment" valign=center>=></span>
<td class="fragment" valign=center>a2a100025d1516bab79163fe862475d7bd010ef8</span>
</table>
<div class="fragment"><i>Everything</i> is a content-addressable object, identified by a <i>hash</i> of itself</div>
</section>
<section>
<h3><i>Everything</i> is an object</h3>
<ul>
<li class="fragment">a file is an object</li>
<li class="fragment">a directory is a list of files, i.e. an object</li>
<li class="fragment">a commit is a top-level directory and a list of parent commits, i.e. an object</li>
</ul>
<span class="fragment"><br />Surprising fact: commits do <i>not</i> store changes!</span>
</section>
<section>
<h3><i>Everything?</i></h3>
Not quite: HEAD is mutable. Mutable things cannot be objects.
</section>
<section>
<h3>The commit graph</h3>
<img src="images/commit-graph.svg" />
</section>
</section>
<section>
<section>
<h3>Starting a topic branch 1/3</h3>
<img src="images/github-mac-branching.png" />
</section>
<section>
<h3>Starting a topic branch 2/3</h3>
<img src="images/github-mac-branching2.png" />
</section>
<section>
<h3>Starting a topic branch 3/3</h3>
<img src="images/github-mac-topic-branches.png" />
</section>
<section>
<h3>Topic branches on the command-line<br /><small>Christopher, this slide is for you again!</small></h3>
<pre>
<code lang="bash" data-trim contenteditable>
$ git checkout -b my-cool-topic origin/master
Switched to a new branch 'my-cool-topic'
...
$ git push origin HEAD
Counting objects: 14, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (8/8), 913 bytes | 0 bytes/s, done.
Total 8 (delta 2), reused 0 (delta 0)
To origin
* [new branch] HEAD -> my-cool-topic
</code>
</pre>
</section>
<section>
<h3>Rewriting branches</br ><spaan style='color: red'>Never, <b>ever</b> rewrite <i>master</i></span></h3>
<pre>
<code lang="bash" data-trim contenteditable>
$ git rebase -i origin/master
Successfully rebased and updated refs/heads/my-cool-topic.
$ git push origin +HEAD
Counting objects: 17, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (12/12), done.
Writing objects: 100% (17/17), 12.75 KiB | 0 bytes/s, done.
Total 17 (delta 3), reused 0 (delta 0)
To origin
+ 597967a...deadbeef HEAD^ -> my-cool-topic (forced update)
</code>
</pre>
</section>
<section>
<h3>"Interactive rebase"</h3>
<pre>
<span style="color: #aca100;">pick</span> <span style="color: #55adbe;">c5ad950</span> <span style="color: #bf08d2;">Insert a comment</span>
<span style="color: #aca100;">pick</span> <span style="color: #55adbe;">1253d09</span> <span style="color: #bf08d2;">Fix typo</span>
<span style="color: #aca100;">pick</span> <span style="color: #55adbe;">dbf553c</span> <span style="color: #bf08d2;">Add support for XYZ</span>
<span style="color: #55adbe;"># Rebase 152ebdc..dbf553c onto 152ebdc
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell</span>
</pre>
</section>
<section>
<h3>Fixup commits</h3>
<pre>
<code lang="bash" data-trim contenteditable>
$ git add bin/
$ git commit --fixup HEAD^^
[master b6c875c] fixup! Insert a comment
1 file changed, 1 insertion(+)
</code>
</pre>
</section>
<section>
<h3>Merging topic branches ("Pull Requests")</h3>
<img src="images/github-mac-pull-request.png" />
</section>
<section>
<h3>Being a good netizen: "Patches welcome"</h3>
<img src="images/i-can-haz-pull-request.png" />
</section>
</section>
<section>
<h3>Bisecting</h3>
<pre>
<code lang="bash" data-trim contenteditable>
$ git bisect start
$ git bisect bad HEAD
$ git bisect good HEAD@{1.day.ago}
... test ...
$ git bisect good
... test ...
$ git bisect bad
... rinse and repeat ...
... find out bad commit ...
$ git bisect reset
</code>
</pre>
</section>
<section>
<section>
<h3>Forking</h3>
<img src="images/github-fork.png" />
</section>
<section>
<h3>Network</h3>
<img src="images/github-network.png" />
</section>
</section>
<section>
<section>
<h3>GitHub tricks</h3>
<ul>
<li>
Looking at individual commits:<br />
<a href="https://github.com/tomancaklab/playground/commit/HEAD^">https://github.com/tomancaklab/playground/commit/HEAD^</a>
</li>
<li class="fragment">
Looking at topic branches:<br />
<a href="https://github.com/tomancaklab/playground/compare/master...tutorial">https://github.com/tomancaklab/playground/compare/master...tutorial</a>
</li>
<li class="fragment">'t'</li>
<li class="fragment">Click on line numbers</li>
<li class="fragment">'y'</li>
<li class="fragment">'?'</li>
<li class="fragment">... more on the <a href="http://fiji.sc/GitHub_Tricks"><i>GitHub Tricks</i></a> page on the Fiji wiki</li>
</ul>
</section>
<section>
<h3>README.md</h3>
<a href="https://help.github.com/articles/github-flavored-markdown">https://help.github.com/articles/github-flavored-markdown</a>
</section>
<section>
<h3><i>gh-pages</i></h3>
See e.g. <a href="http://scijava.github.io/">http://scijava.github.io/</a>, backed by <a href="https://github.com/scijava/scijava.github.com">https://github.com/scijava/scijava.github.com</a>.
</section>
</section>
<section>
<h1>Thank you!</h1>
<p>ImageJ2/Fiji team<br />(original authors of this workshop):</p>
<p class="gallery"><img src="images/kevin-eliceiri.jpg" /><img src="images/curtis.jpg" /><img src="images/dschos-pony.jpg" /><img src="images/mark-hiner.jpg" /></p>
</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
// 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>