-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
585 lines (497 loc) · 23.7 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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Git and GitHub Tips and Tricks - SGVLUG 2016-05-12 (Revised)</title>
<meta name="description" content="Reprise of a presentation given to the monthly San Gabriel Valley Linux User Group meeting on 2014-10-09. Topic: Git and GitHub.">
<meta name="author" content="Lan Dang">
<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/solarized.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 data-markdown>
<script type="text/template">
#Git and GitHub Tips and Tricks
###San Gabriel Valley Linux User Group
####2016-05-12
#####(Though nothing much has changed since I gave talk on 2014-10-09)
http://ldang.github.io/git-github-slides
Presented by Lan Dang
</script>
<aside class="notes">
</aside>
</section>
<section>
<section data-markdown>
<script type="text/template">
# Introductions
</script>
<aside class="notes">
</aside>
</section>
<section data-markdown>
<script type="text/template">
### About the talk
------------------
* This is version 0.1 of a planned sequel to [Distributed Version Control Systems (DVCS) & Mercurial](http://bit.ly/10OIsby)
* Will be reprised at a future LUG talk, when I have more time to work on it
* All I want is for you to learn something you didn't already know about Git or GitHub
* Questions and comments welcome; feel free to interrupt
* No live demo
</script>
<aside class="notes">
</aside>
</section>
<section data-markdown>
<script type="text/template">
### About the slides
--------------------
* HTML5 presentation framework: [reveal.js framework](https://github.com/hakimel/reveal.js/)
* See all the iterations of my slides--yes, this was a last-minute thing
https://github.com/ldang/git-github-slides/
* This presentation is being served on my local machine, but it can also be viewed on GitHub
https://ldang.github.io/git-github-slides
NOTE: My local copy will be more up-to-date than the GitHub copy until I'm finished.
</script>
<aside class="notes">
</aside>
</section>
<section data-markdown>
<script type="text/template">
### About me
------------
* I spend a lot of time logged into remote Linux machines
* I love the command line
* I am not a Git/GitHub expert, but I have a professional interest in distributed version control
* I am not a software developer, though I occasionally play one at work
* I write tools using primarily shell scripts with the occasional dash of Python
* My favorite tools are bash, awk, vim, GNU screen, git, GitHub
</script>
<aside class="notes">
</aside>
</section>
<section data-markdown>
<script type="text/template">
### About Git
-------------
* Distributed version control system
* "Time machine" for text files
* Often pre-installed on Linux systems
* A bit of a learning curve
* GUIs are available, but you still need the command line for some of the advanced functionality
</script>
<aside class="notes">
</aside>
</section>
<section data-markdown>
<script type="text/template">
### About GitHub (1)
--------------------
* Collaboration platform, originally meant for software projects
* Access control and organization system
* Git/Subversion repository hosting
* Issue tracking
* Wiki
* GitHub Pages (project web pages)
* GitHub Gists (version-controlled pastebin)
</script>
<aside class="notes">
</aside>
</section>
<section data-markdown>
<script type="text/template">
### About GitHub (2)
--------------------
* Free for public repositories, and there is affordable pricing scheme if you need private repositories
* User-friendly. Easy to use, and you get hints all the time of how to do things
* Gists are basically lightweight repositories, which are great for just dumping code fragments or how-tos
* You can edit the files in the repository using the web interface
* GitHub-flavored Markdown - a source code-friendly version of Markdown to write documentation
* Encourages code remix and reuse and collaboration through forking and pull requests
</script>
<aside class="notes">
</aside>
</section>
<section data-markdown>
<script type="text/template">
### About GitHub (3)
--------------------
* GitHub Enterprise is self-hosted version aimed at companies that want to keep their repositories in-house.
* Makes it easy for everyone to practice version control without overhead of running own server
* Encourages sharing of code, so we can learn from each other and not reinvent the wheel
* Good way to share domain knowledge because we can provide documentation as well as source code
* Desktop apps: GitHub GUI for Mac, Atom text editor, Gollum wiki software
* Extensive Git/GitHub training material available [here](https://training.github.com/)
</script>
<aside class="notes">
</aside>
</section>
</section>
<section>
<section data-markdown>
<script type="text/template">
#Basics
</script>
<aside class="notes">
</aside>
</section>
<section data-markdown>
<script type="text/template">
### Turning a directory into a Git repository
---------------------------------------------
* Assuming git is already installed
```
cd test_repo
# Initialize git repository
git init
# Add the contents of the current directory to be tracked by git
git add .
git commit -m "Initial commit"
```
</script>
<aside class="notes">
</aside>
</section>
<section data-markdown>
<script type="text/template">
### Making a new repository in GitHub
-----------------------------------
* Go to GitHub website. (Helpful if you are already logged in.)
https://github.com/new
* Follow the instructions. GitHub gives you many options; pick the one that matches your situation
* This is how I posted these slides to GitHub, using a git repository I already had.
```
cd git-github-talk-2014-10-09
git remote add origin [email protected]:ldang/git-github-slides.git
# Push a local branch to a remote repo for the first time
# origin is usually what we call the remote repo we cloned from
git push -u origin master
```
</script>
<aside class="notes">
</aside>
</section>
<section data-markdown>
<script type="text/template">
###GitHub-Flavored Markdown
* GitHub supports [Markdown](http://daringfireball.net/projects/markdown/syntax) as one of the ways to format text on GitHub in issues, gists, wikis, text files.
* GitHub-Flavored Markdown is a variant of Markdown that includes some extra syntax and a slight change in behavior to make it more source code and GitHub-friendly. See [here](https://help.github.com/articles/github-flavored-markdown/) for documentation.
* [Here](https://help.github.com/articles/writing-on-github/) is more advice on how to format text on GitHub.
</script>
<aside class="notes">
</aside>
</section>
<section data-markdown>
<script type="text/template">
### Committing changes
-----------------------
* New files need to be registered with the repository before git will "track" it.
```
# Adds the current directory and all files in it
git add .
```
* By default, git only commits changes that are staged, usually using "git add"
```
git add newfile
git commit -m "Adding new files"
```
* You can just commit everything using the -a option. But this only commits changes to tracked files. You still need to explicitly add new files.
```
git commit -a -m "Saving changes"
```
</script>
<aside class="notes">
</aside>
</section>
<section data-markdown>
<script type="text/template">
###Git tutorial
* Full tutorial is beyond scope of this talk
* Atlassian has an excellent set of tutorials for Git, particularly if you are coming from Subversion.
https://www.atlassian.com/git/tutorials
</script>
<aside class="notes">
</aside>
</section>
</section>
<section>
<section data-markdown>
<script type="text/template">
#Tips
</script>
<aside class="notes">
</aside>
</section>
<section data-markdown>
<script type="text/template">
### Best practices for log messages
-----------------------------------
* If you are doing short log messages, you can just embed it in the commandline
```
git commit -m "This is my log message"
```
* If you are doing fairly long messages, then commit without "-m" option; git will open up your default text editor
```
git commit
```
* When writing multi-line log messages, the first line should be crafted carefully to summarize the commit. There are many ways of looking at the git log, and some of them are very compact and only show the first line.
</script>
<aside class="notes">
</aside>
</section>
<section data-markdown>
<script type="text/template">
### Best practices for repository management
--------------------------------------------
* Find a central place to organize your repositories, no matter how trivial the repos are.
* The power of distributed version control is that it is *distributed*
* It is your backup if you mess up your working repository
* Even if you lose your current work, that should only set you back a few hours, not weeks
* This central place is easy to backup for automated backups.
* It is easy to identify as the place most likely to have the most complete version of the repository.
* You may have use cases where you have one or more clones of the repository on various machines
* For many people, this central place is GitHub. For other people, it is a bare repo in their home directory
</script>
<aside class="notes">
</aside>
</section>
<section data-markdown>
<script type="text/template">
### Bare repositories (1)
-------------------------
* A git repository normally consists of the repository (in a hidden .git folder) and the set of working files and directories that represent the state of the repository at a given point in time.
* The working files are only useful if you're actually working on them. Otherwise, they just take up space.
* There are cases where you want a bare repository
* As a way to share your git repository with other people
* As a way to backup your git repository
* A bare repository is a repository that doesn't have a working directory
* Bare repositories are usually initialized and cloned. Changes are synchronized via pushing and pulling.
</script>
<aside class="notes">
</aside>
</section>
<section data-markdown>
<script type="text/template">
### Bare repositories (2)
-------------------------
```
# bare repositories usually have naming convention <repo>.git
git init ~/my_new_repo.git
mkdir my_test
git clone ~/my_new_repo.git
touch README
git commit -am "Initial commit"
git push
```
</script>
<aside class="notes">
</aside>
</section>
<section data-markdown>
<script type="text/template">
###Changing a remote's URL
--------------------------
* You can map names to remote repositories. By default, the remote repository you clone is known as "origin"
* When you establish a link to a remote repo, you can designate a different name
* Sometimes, you want to change what "origin" points to. Apparently, one reason may be that you want to change how you are accessing the remote Git repo--usually changing from HTTPS to SSH. (GitHub has a [tutorial](https://help.github.com/articles/changing-a-remote-s-url/) regarding this.)
* When you authenticate over HTTPS, GitHub will ask for your username and password
* If you use SSH, you can setup SSH key authentication instead. You can upload your public key to your GitHub profile.
```
git remote set-url origin [email protected]:user/repo2.git
```
</script>
<aside class="notes">
</aside>
</section>
<section data-markdown>
<script type="text/template">
###Using Gists for Cheatsheets
----------------------------
* Make new gists here: https://gist.github.com/
* After you create the gist, you'll see some links in the right-hand column
* You can clone gists. The advantage is that you can use your favorite text editor to edit the gist, as well as having a local copy of the gist.
Consider this an easter egg; it's a file I keep on my hard drive that compiled all the useful commands from a GitHub training class I attended
[Useful Git Commands](https://gist.github.com/ldang/e6be1032c6a59cf2dbca)
* Note: While you can make public or secret gists, there is no access control on the gists themselves. If you know the URL, you can get to the gist.
</script>
<aside class="notes">
</aside>
</section>
</section>
<section>
<section data-markdown>
<script type="text/template">
#GitHub Pages
</script>
<aside class="notes">
</aside>
</section>
<section data-markdown>
<script type="text/template">
###Publishing a webpage on GitHub (1)
--------------------------------------
* GitHub has a feature called [GitHub Pages](https://pages.github.com/), which is aimed to provide minor webhosting ability for project or organization websites.
* Many people use this feature purely to host websites or blogs or slides
* Documentation [here](https://help.github.com/categories/github-pages-basics/)
</script>
<aside class="notes">
</aside>
</section>
<section data-markdown>
<script type="text/template">
###Publishing a webpage on GitHub (2)
--------------------------------------
* You can manually set it up using the git command line
* gh-pages is a special branchname to GitHub. It is assumed that whatever is published to the gh-pages branch can be served up by a webserver
* Additionally, GitHub automatically renders Markdown as HTML, so you can even publish Markdown documents and have it show up as styled HTML
* So basically, all you have to do is to make sure that you have a gh-pages branch and that it contains the files needed for the webpage
</script>
<aside class="notes">
</aside>
</section>
<section data-markdown>
<script type="text/template">
###Publishing a webpage on GitHub (3)
-------------------------------------
This is how I "published" my slides on GitHub pages
```
# Go into my git repo, which is already connected to GitHub
cd git-github-talk-2014-10-09
# Make a new branch gh-pages
git checkout -b gh-pages
# Push this new branch back to GitHub
git push -u gh-pages
```
</script>
<aside class="notes">
</aside>
</section>
<section data-markdown>
<script type="text/template">
###Publishing webpages on GitHub (4)
--------------------------------
* When working with webpages, it's usually a good idea to do the editing on a development branch or on master
* When you are ready to update the webpage itself, then you can push those updates to the gh-pages branch
* GitHub has some server-side processes that does a little processing to complete the publication process.
* A side effect is that your updates may take a little bit of time to go live.
</script>
<aside class="notes">
</aside>
</section>
<section data-markdown>
<script type="text/template">
###Publishing webpages on GitHub (5)
--------------------------------
Example, where development was done on the master branch
```
# go to gh-pages branch
git checkout gh-pages
# Bring in changes from master branch
git rebase master
# Push the changes in gh-pages to GitHub
git push origin gh-pages
# go back to master and do more development
git checkout master
```
</script>
<aside class="notes">
</aside>
</section>
</section>
<section data-markdown>
<script type="text/template">
#Questions?????
https://github.com/ldang/git-github-slides/issues
</script>
<aside class="notes">
</aside>
</section>
<section>
<section data-markdown>
<script type="text/template">
### Reference
--------------
* Links to various videos about Git and Mercurial and distributed version control
https://gist.github.com/ldang/fcd53c084fdf3f690c36
</script>
<aside class="notes">
</aside>
</section>
</section>
<section>
<section data-markdown>
<script type="text/template">
# Backup slides aka more ideas
</script>
<aside class="notes">
</aside>
</section>
<section data-markdown>
<script type="text/template">
* Forking
* Pull request
* Directed acyclic graphs
* Anatomoy of a git commit
* Rewriting history
* Git Reflog
* Basic merge algorithm
* Git-svn and converting between other VCS
* Git history - credit to Linux Torvalds
* Reference pages
</script>
<aside class="notes">
</aside>
</section>
</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>