-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
562 lines (383 loc) · 9.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
<!DOCTYPE html>
<html>
<head>
<title>Practical Git tips and tricks</title>
<meta charset="utf-8">
<style>
@import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz);
@import url(https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic);
@import url(https://fonts.googleapis.com/css?family=Ubuntu+Mono:400,700,400italic);
.remark-slide-content { font-size: 2.4em; }
body {
font-family: 'Droid Serif';
}
h1, h2, h3 {
font-family: 'Yanone Kaffeesatz';
font-weight: normal;
color: #1DE986;
}
div.remark-slide-content {
background-color: black;
color: white;
}
.large { font-size: 2em; }
.small { font-size: 0.5em; }
.footnote {
position: absolute;
bottom: 3em;
text-align: right;
color: #B7B7B7;
font-size: 0.7em;
}
.fastdev-green { color: #1DE986; }
.fastdev-light-gray { color: #B7B7B7; }
.fastdev-dark-gray { color: #666666; }
.fastdev-red { color: #EA5355; }
.sportamore-pink {color: #F32E9D;}
img {
max-width: 100%;
max-height: 100%;
}
.image-10 img { width: 10%; }
.image-20 img { width: 20%; }
.image-30 img { width: 30%; }
.image-40 img { width: 40%; }
.image-50 img { width: 50%; }
.image-60 img { width: 60%; }
.image-70 img { width: 70%; }
.image-80 img { width: 80%; }
.image-90 img { width: 90%; }
.remark-code, .remark-inline-code {
font-family: 'Ubuntu Mono';
font-size: 0.8em;
background: #222222;
border-radius: 5px;
}
</style>
</head>
<body>
<textarea id="source">
name: title
class: center, middle
# Practical Git tips and tricks
![GitHub](images/github.png) .fastdev-gray[tipishev/git_workshop]
---
# Motivation
* refresh memory
* rekindle interest in Git
* simplify workflow
???
* use it every day ⇒ learn it inside out
* new city metaphor
- at first you read about it, try to explore every bit and corner
- but then gradually set into work-supermarket-home routine
* guide to hidden corners
* productive and fun
* don't expect to remember everything
--
.footnote[\* myself included]
---
# Sportamore Setup
- Github + Teamcity
- feature ➔ .sportamore-pink[dev] ➔ master
???
* this detail explains why my examples pull dev instead of master
---
# Naïve Version Control
![Naïve Version Control](images/naive_version_control.png)
???
* explain version control to non-developers
* they are baffled by its complexity
---
# Do we need this complexity?
.center.image-50[![Advanced](images/advanced.png)]
???
* as if it were the same guy who made Linux
---
# Maybe Not...
.center.image-50[![Basic Gearshift](images/basic_gearshift.png)]
--
```bash
git help everyday
```
???
* after all only a handful of commands is used
* learn 20 commands in 20 minutes
---
# Le·git ([git-legit.org](http://www.git-legit.org/))
![Legit](images/legit.png)
???
* Kenneth Reitz, creator of the main Python web-lib
* Just 7 commands
---
# Pro-git
.center.middle.image-50[![Pro Git](images/pro-git.png)]
???
* as any bible available in all human languages
* that's where most of the tricks come from
---
# Configuration
* .fastdev-red[`--system`] for all users
* .fastdev-red[`--global`] just for you
* .fastdev-red[`--local`] for the project
???
* first thing, configuration
* easy and rewarding
* whenever we see a new application and device we go to settings
* in most cases --global an --local config is useful
--
* ~~.fastdev-red[`--emperor`] FOR THE EMPRAH!~~
???
---
# Examples
* Aliases
???
* aliases.sh
---
# Aside: Sexy Bash Prompt
![Sexy Bash Prompt](images/sexy-bash-prompt.png)
???
* recommend installing it or similar if using git command line
* saves typing 'git status' or 'git st'
---
# Examples
* Aliases
* Autocorrect
???
* the next immediately useful feature
- autocorrect.sh
--
* Colors
???
* aesthetics
- colors.sh
---
# Other Configuration Tips
* Always rebase on pull
`git config --global pull.rebase true`
* 3-way diff
`git config --global merge.conflictstyle diff3`
* See all configs values*
`git config --list`
--
.footnote[\* you may be surprised]
???
* 3-way diff, why did they drift apart
---
# Git Hooks
* Enforce rules
* Trigger actions
???
- Python3 modernization: app-by-app
- refresh ctags on checkout
- avoid commiting secrets or unlinted code
--
----
* Remote - enforced
* Local - optional*
--
.footnote[\* Can be bypassed with `--no-verify`]
---
# Git Hooks
![Git Hooks](images/git-hooks.png)
???
* hooks.sh
---
# Archeology
## `git-grep`
* faster than `grep`
* useful flags
- `--count`
- `--line-number`
- `--show-function`
???
* happens all the time with long-running projects
* refactoring
* what were they ~~smoking~~ thinking
* grep.sh
---
## Blame
`git blame`
* the starting point
* likely to blame refactorer
* ignore-flags
- .fastdev-red[`-w`] white space
- .fastdev-red[`-M`] moving within file
- .fastdev-red[`-C`] moving between files
???
* JetBrains IDE as "Annotate"
* Shows the author, commit hash, timestamp
* flags protect the innocent
---
## Pickaxe
`git log -S {string}`
.fastdev-red[The ultimate code-digging tool across the whole history]
---
# Realism vs Perfection
* aka .fastdev-red[Sausage Making]
???
* an actual name, see link in README.MD
* as any practical matter, requires balanced approach
* matters at PR
--
* Realism
- better for historians
--
* Perfection
- easier to read
???
* commit often
* perfect later
* publish once
---
# Tools
* separate commits (`-p`)
* separate branches
* interactive rebasing
--
.fastdev-green[\> asuming not pushed yet]
[Choose your own Git adventure!](http://sethrobertson.github.io/GitFixUm/fixup.html)
???
* Git is forgiving until push
* patch.sh
---
![Drive-By Refactoring](images/drive-by.png)
---
# Refactoring Branch
* `feature/XXX-666-refactoring` -> `dev`
* `feature/XXX-666` -> `feature/XXX-666-refactoring`
![Trident](images/trident.png)
---
# Interactive Rebasing
* `git commit --amend` on steroids
* a range of unpushed commits
* pretend to be perfect
???
* amend: rewrite the latest commit
* rebasing.sh
---
# Bisect
![Binary-Search](images/binary-search.png)
???
* bisect.sh
---
# Bisect Ideas
* (.fastdev-green[old], .fastdev-red[new]) == (.fastdev-green[good], .fastdev-red[bad])
* Mark >1 good commit
* Bisect broken test on CI
---
# Git Attributes
* tell Git how to treat files
* Like `gitconfig`:
- `system`
- `global`
- `local`
---
# Git Worldview
* Text Files
* Binary Files
.small[
```
diff --git a/binary/notes.docx b/binary/notes.docx
index 638f1d4..9934c87 100644
Binary files a/binary/notes.docx and b/binary/notes.docx differ
```
]
---
# Binary Deception
.center.image-50[![Binary Deception](images/deception.png)]
* some .fastdev-red[text] is as good as binary
* some .fastdev-green[binaries] are just text
???
* real world not white and black
* .gitattributes tells Git how to treat files
* binary.sh
---
# Filters
## Smudge (on `checkout`)
![Smudge](images/smudge.png)
---
# Filters
## Clean (on `add`)
![Clean](images/clean.png)
???
* filters.sh
---
# Filters: Diff Images
```bash
*.png diff=exif
git config diff.exif.textconv exiftool
diff --git a/image.png b/image.png
```
.small[```
index 88839c4..4afcb7c 100644
--- a/image.png
+++ b/image.png
@@ -1,12 +1,12 @@
ExifTool Version Number : 7.74
-File Size : 70 kB
-File Modification Date/Time : 2009:04:21 07:02:45-07:00
+File Size : 94 kB
+File Modification Date/Time : 2009:04:21 07:02:43-07:00
File Type : PNG
MIME Type : image/png
-Image Width : 1058
-Image Height : 889
+Image Width : 1056
+Image Height : 827
Bit Depth : 8
Color Type : RGB with Alpha
```]
---
# Filters: Mask Markdown As Word
![Word](images/word.png)
* smudge: markdown to Word
* clean: Word to markdown
---
# Filters: Transparent Encryption
![Tinfoil](images/tinfoil.png)
* smudge: decrypt
* clean: encrypt
* .fastdev-red[required] keyword
.small.fastdev-light-gray[https://gist.github.com/g-k/9087422]
---
# Miscellaneous Tips
* The power of `-`
- `git checkout -`
- `git merge -`
* Git Stash
- `git stash save "Jim asked to fix FOO while I was doing BAR"`
- `git stash list`
- `git stash pop`
* See what's shaking with
`git for-each-ref --sort=-committerdate --format='%(refname:short) %(committerdate:short)'`
---
# Miscellaneous Tips (continued)
* insta-checkout file from another branch with
`git checkout <branch> -- filename`
* git replace
`git grep -l $1 | xargs sed -i 's/$1/$2/g'`
* follow file changes
`git log --follow -p -- index.html`
---
# ~~Conclusion~~ Call to Action
* a couple of aliases
--
* create a `#git-fu` channel and share your most useful trick
--
* download .middle.image-30[![Pro Git](images/pro-git.png)].epub
to your phone
???
* [write yourself a git](https://wyag.thb.lt/)
---
class: center, middle
# ¿Questions?
???
Now we still have time left, so I can answer your questions.
</textarea>
<script src="https://remarkjs.com/downloads/remark-latest.min.js">
</script>
<script>
var slideshow = remark.create();
</script>
</body>