-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-talk.typ
More file actions
394 lines (282 loc) · 8.71 KB
/
git-talk.typ
File metadata and controls
394 lines (282 loc) · 8.71 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
#import "@preview/polylux:0.4.0": *
#set page(
paper: "presentation-16-9",
footer: align(right, text(size: 9pt, toolbox.slide-number)),
margin: auto,
)
#set text(
font: "Segoe UI",
size: 18pt,
)
#let sc(content) = text(features: ("c2sc",))[#content]
#show regex("[A-Z]{2,}"): match => {
sc(match)
}
// #show math.equation: set text(font: "STIX Two Math")
#show heading: set block(below: 2em)
// link properties
#show cite: set text(fill: maroon) // set cite colour
#show ref: set text(fill: rgb(0, 0, 128)) // set reference colour
#show link: set text(fill: rgb(0, 0, 255)) // set link colour
#show link: underline
#show footnote: set text(fill: maroon)
#show footnote.entry: set text(fill: maroon)
// title slide
#slide[
#set page(footer: none)
#set align(center + horizon)
#toolbox.side-by-side[
#rect(height: 1.2fr)[#image("/inc/final.png")]
][
#text(1.8em)[*VERSION CONTROL \ _for_ \ ENGINEERS*]
_The art of tracking (atomic) changes with git_
C Kunte \ August 2024
]
]
#slide[
#set page(columns: 2)
#outline(depth: 2)
]
#slide[
#set align(center + horizon)
= Version control
]
#slide[
#toolbox.side-by-side[
== Why?
- recording change explicitly
- #highlight[atomic level traceability]
- #highlight[better diffs]
- #highlight[full history access]
- branch out #sym.arrow.r work on parts #sym.arrow.r merge back
- reuse, collaboration
- disciplined work
- habit worth cultivating
][
== Types
/ CVCS: centralised
/ DVCS: distributed
== Software
/ 1986: CVS
/ 1992: TeamWare
/ 2000: Subversion, BitKeeper
/ 2003: Monotone
/ 2005: *git*, Mercurial
]
]
#slide[
#set page(columns: 2)
= git
- DVCS, portable
- a bunch of CLI programs (100+)
- great software; bad UI/UX
- open source and free
- GUI clients == sanity
- originally designed for linux FS; now available for all OSes
- for tracking #highlight[plain text] files
- not useful for tracking binary files (no diffs)
== Background
/ 1991: Linus begins a hobby project called *linux*
/ 2005: Linus creates *git* to manage linux including kernel code contributions from others
/ 2008: GitHub is born, makes git very popular; git captures #highlight[94% of market] by 2022
]
#slide[
= How to version control with git
#toolbox.side-by-side[
#set align(center + horizon)
#rect(stroke: none, height: 1fr)[#image("/inc/git-xkcd.png")]
][
== Steps, basic commands
+ Initialise a working folder
+ Check status
+ #highlight[Add (i.e. stage) files]
+ #highlight[Commit new and changed files]
+ List commits
```bash
git init # initialise
git status # check status
git add # stage file(s)
git commit # commit changes
git log # list commits
```
]
]
#slide[
= init, add, commit
```bash
$ git init
Initialized empty Git repository in ~/model/.git/
$ git add README.md
$ git commit -m "Add README file"
[master (root-commit) 74218c0] Add README file
1 file changed, 1 insertion(+)
create mode 100644 README.md
```
]
#slide[
#set align(center + horizon)
= What just happened?
]
#slide[
#set page(columns: 2)
== git init
- creates a subfolder named `.git` within the working folder
- `.git` folder collects #highlight[filesystem snapshots] of the working folder
== git add
- for tracking files of interest, they first need to be added
== git commit
- a command for taking a filesystem snapshot (of added files)
- uses secure hash algorithm (SHA) #sym.arrow.r for data integrity
- #highlight[commits never change]\; IDs are #highlight[computed from their contents]
- Designed initially with SHA1; now using SHA256 to avoid collision
- Every commit hash is #highlight[40 bytes] long to #highlight[ensure uniqueness]
]
#slide[
#set align(center + horizon)
= commit -- a two-stage process
+ *add* files (new, changed)
+ *commit* (new, changed)
i.e., recording change _explicitly_
]
#slide[
#set align(center + horizon)
= git status
#figure(
image("/inc/status.png", height: auto),
) <status>
]
#slide[
#set align(center + horizon)
= git log
#figure(
image("/inc/smerge.png", height: auto),
) <sm1>
]
#slide[
#set align(center + horizon)
= Demo.
_Switch to Terminal and Sublime Merge_
]
#slide[
= .gitignore
- git has a provision for ignoring files of disinterest
- `.gitignore` file in the repository does the job
#toolbox.side-by-side[
*Exclude* example
```bash
*.pdf
*.xlsx
```
][
*Only include* example
```bash
*
!*.inp
```
/ `*`: to ignore all, followed by
/ `!`: to include only `.inp` files
]
]
#slide[
#set align(center + horizon)
= Configuring git
]
#slide[
= .gitconfig
- Handy if commits are pushed to a remote server
- Cryptographic identity in the open-source world is fundamental
- Commits signed with digital keys to prevent author spoofing
- GPG or SSH keys used for signing commits, pushing to remote
```bash
[user]
name = Chetan Kunte
email = <my email address>
signingkey = ~/.ssh/<my_signing_key>.pub
[commit]
gpgsign = true
[tag]
gpgsign = true
[gpg]
format = ssh
[gpg "ssh"]
allowedSignersFile = ~/.ssh/allowed_signers
[init]
defaultBranch = master
[core]
autocrlf = input
```
#v(1fr)
_Line endings_
/ LF: line feed (`\n`) in UNIX-like OSes
/ CRLF: carriage return, followed by line feed (`\r\n`) in Windows
]
#slide[
= Best practices
- make small, incremental changes
- keep commits atomic
- test before committing
- get feedback through (e.g. peer) reviews
- avoid committing incomplete work (units) and unnecessary files
- commit often
- write clear and concise commit messages
- develop using branches (treat 'master' or 'main' branch sacred)
- agree on a workflow / branching strategy
- keep the repository clean and up to-date
]
#slide[
#set align(center + horizon)
= Buying tools?
#quote(block:true, attribution: [Kevin Kelly])[
_Start with the cheapest. Upgrade the ones that you use a lot. If you use for work, then buy the very best you can afford._
]
]
#slide[
= GUI clients _for_ git
+ Sublime Merge (a personal favourite)
- by Sublime HQ (makers of Sublime Text), Australian
- pretty good software
- never have to see command line, if you so wish
- feature complete, very easy to use, clean interface
- commercial:
- personal license: \$99/3y (allowed at work)
- commercial license: \$75/y
- trial period unlimited; all features available, no catch, be fair
+ try others (many are free): #link("https://git-scm.com/downloads/guis")[git-scm.com/downloads/guis]
]
#slide[
= [Re] learn to use command line interface
- a query-response system
- learn from MIT course #footnote[_The missing semester of your CS education_, #link("https://missing.csail.mit.edu")[missing.csail.mit.edu]]
- Windows ships with linux (_aka_ Windows Subsystem for linux)
- alternatively, get a cheap SBC (e.g., Raspberry Pi) to try linux
- practice doing things in command line, it is
- powerful and versatile
- very low on resource demand
]
#slide[
= Recap
+ git -- today's _state of the art_ in version control, portable, distributed
+ a _two-stage_ process, i.e., add, commit
+ every commit is a _snapshot_ of working folder's filesystem
+ git computes diffs between commits on the fly, very fast
+ git is like a machine for time-travel through file (or model) history
+ works best with _plain text_ files, not useful for binary files (no diffs)
+ all history resides within `.git` subfolder under the working folder
]
#slide[
= Resources
- `git help everyday` -- most helpful beginner's command
- git source code management (#link("https://git-scm.com")[git-scm.com])
- git GUI software (#link("https://git-scm.com/downloads")[git-scm.com/downloads])
- git guides (#link("https://github.com/git-guides")[github.com/git-guides])
- getting git right (#link("https://www.atlassian.com/git")[atlassian.com/git])
- github docs (#link("https://docs.github.com/en")[docs.github.com/en])
- a git history (#link("https://blog.brachiosoft.com/en/posts/git/")[blog.brachiosoft.com/en/posts/git/])
- "how git works" illustrated by J Evans (#link("https://wizardzines.com/zines/git")[wizardzines.com/zines/git])
- Linus's talk about git c. 2007 (#link("https://youtu.be/MjIPv8a0hU8")[youtu.be/MjIPv8a0hU8])
- K Healy, Duke Uni., "Modern Plain Text Computing," #link("https://mptc.io")[mptc.io]
]
#slide[
#set align(center + horizon)
#text(1.5em)[*Thank you. Questions?*]
]