-
Notifications
You must be signed in to change notification settings - Fork 26
/
index.html
338 lines (322 loc) · 13.9 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
<!doctype html>
<html lang="en-ca">
<head>
<title>GitTogether</title>
<link rel="stylesheet" href="css/reveal.css" />
<link rel="stylesheet" href="css/theme/moon.css" />
<link rel="stylesheet" href="css/presentation.css" />
</head>
<body>
<div class="reveal">
<div class="slides">
<section data-transition="convex">
<h2>Git Together</h2>
<p>
Inspired by
<a href="https://www.youtube.com/playlist?list=PLWKjhJtqVAbkFiqHnNaxpOPhh9tSWMXIF">
freeCodeCamp's tutorial series
</a>
</p>
</section>
<section data-transition="convex">
<section data-transition="convex">
<h2>Git vs GitHub</h2>
</section>
<section data-transition="convex">
<h3>Git</h3>
<ul>
<li>Version Control Software (VCS)
<ul>
<li>Time capsule</li>
</ul>
</li>
<li>Open Source
<ul>
<li><a href="https://git-scm.com">git-scm</a></li>
</ul>
</li>
</ul>
</section>
<section data-transition="convex">
<h3>GitHub</h3>
<h4>or GitLab</h4>
<ul>
<li>Collaboration site</li>
<li>Interacts with Git</li>
</ul>
</section>
</section>
<section data-transition="convex">
<section data-transition="convex">
<h2>Setting up Git</h2>
</section>
<section data-transition="convex">
<img src="images/newRepo.PNG" alt="GitHub New Repository" />
<footer>*Don't forget the open-source license!</footer>
</section>
<section data-transition="convex">
<h3>Cloning</h3>
* If you are cloning somebody else's repo, Fork it first
<ol>
<li class="fragment" data-fragment-index="1">
Copy the URL for the new repo
</li>
<li class="fragment" data-fragment-index="2">
Open Git Bash in your working directory
</li>
<li class="fragment" data-fragment-index="3">
<code data-trim data-noescape>
$ git clone <mark>https://github.com/CCSudbury/GitTogether</mark>
</code>
</li>
</ol>
</section>
<section data-transition="convex">
<h3>Initializing</h3>
<ol>
<li class="fragment" data-fragment-index="1">
Open the working directory
</li>
<li class="fragment" data-fragment-index="2">
Write your first bit of code
</li>
<li class="fragment" data-fragment-index="3">
<code data-trim data-noescape>
git init; git add . ; git commit
</code>
</li>
<li class="fragment" data-fragment-index="4">
Connect to GitHub
<ol class="fragment" data-fragment-index="5" style="list-style-type: lower-alpha">
<li>Create a new repo</li>
<li>Push an existing repository</li>
<li>
<code data-trim data-noescape>
$ git remote add origin https://github.com/username/new_repo
$ git push -u origin master
</code>
</li>
</ol>
</li>
</ol>
</section>
</section>
<section data-transition="convex">
<section data-transition="convex">
<h2>Branching and Workflow</h2>
</section>
<section data-transition="convex">
<h3>4 things to remember in a Git workflow</h3>
<ol>
<li class="fragment" data-fragment-index="1">Branching
<ul>
<li class="fragment" data-fragment-index="1">
Good practice not to work directly on master*
</li>
</ul>
</li>
<li class="fragment" data-fragment-index="2">Commits
<ul>
<li class="fragment" data-fragment-index="2">
As many or few as you want!
</li>
</ul>
</li>
<li class="fragment" data-fragment-index="3">Collaborate
<ul>
<li class="fragment" data-fragment-index="3">
Maybe make some more commits/changes
</li>
</ul>
</li>
<li class="fragment" data-fragment-index="4">Merge
<ul>
<li class="fragment" data-fragment-index="4">Pray</li>
</ul>
</li>
</ol>
</section>
</section>
<section data-transition="convex">
<h2>Workflow for Open Source</h2>
<section data-transition="convex">
<h3>Forking</h3>
<ul>
<li>A snapshot of the project under your personal account</li>
</ul>
</section>
<section data-transition="convex">
<h3>Pull Request</h3>
<ul>
<li>Send the modifications made on your snapshot back to the project</li>
</ul>
</section>
</section>
<section data-transition="convex">
<section data-transition="convex">
<h2>Cloning and Working Locally</h2>
</section>
<section data-transition="convex">
<h3>Cloning</h3>
<ol>
<li>IDE</li>
<li>Desktop app</li>
<li>Command Line (Windows, UNIX, Git Bash)</li>
</ol>
</section>
<section data-transition="convex">
There are two* places Git repos are stored
<ul>
<li>Remote (GitHub)</li>
<li>Locally (your computer)</li>
<li class="fragment" data-fragment-index="1">Locally (friend's computer)</li>
<li class="fragment" data-fragment-index="2">Locally (co-worker's computer)</li>
<li class="fragment" data-fragment-index="3">Locally (boss' computer)</li>
<li class="fragment" data-fragment-index="4">...</li>
</ul>
</section>
</section>
<section data-transition="convex">
<section data-transition="convex">
<h2>Most Used Commands</h2>
</section>
<section data-transition="convex">
<ul>
<li class="fragment" data-fragment-index="1">
<code data-trim data-noescape>
git clone
</code>
</li>
<li class="fragment" data-fragment-index="2">
<code data-trim data-noescape>
git pull/fetch
</code>
</li>
<li class="fragment" data-fragment-index="3">
<code data-trim data-noescape>
git branch feature-branch
</code>
</li>
<li class="fragment" data-fragment-index="4">
<code data-trim data-noescape>
git checkout feature-branch
</code>
</li>
<li class="fragment" data-fragment-index="5">
<code data-trim data-noescape>
git status
</code>
</li>
<li class="fragment" data-fragment-index="6">
<code data-trim data-noescape>
git diff
</code>
</li>
<li class="fragment" data-fragment-index="7">
<code data-trim data-noescape>
git add .
</code>
</li>
<li class="fragment" data-fragment-index="8">
<code data-trim data-noescape>
git commit [-m]
</code>
</li>
<li class="fragment" data-fragment-index="9">
<code data-trim data-noescape>
git push
</code>
</li>
</ul>
</section>
</section>
<section data-transition="convex">
<h2>How Commits Work</h2>
<ul>
<li>
Each commit has a unique ID of 40 characters (SHA-1 Hash) containing information about the commit such as the parent commit
</li>
</ul>
</section>
<section data-transition="convex">
<section data-transition="convex">
<h2>2-step Commit</h2>
</section>
<section data-transition="convex">
Git has three sections:<br>
<ol>
<li>Working Directory</li>
<li>Staging Area</li>
<li>History</li>
</ol>
<section data-transition="convex">
<code data-trim data-noescape>git add</code> moves from PWD to Staging
<code data-trim data-noescape>git commit</code> moves from Staging to History
</section>
</section>
<section data-transition="convex">
Example:
<ul>
<li>Working on a website you edit a few pages, but you also add some missing images from another page.</li>
<li>You can add and commit them independently to highlight that the changes were not related</li>
</ul>
</section>
</section>
<section data-transition="convex">
<h2>Merging</h2>
<ul>
<li>Let's bring those changes back to the project</li>
<li>
Use <code data-trim data-noescape>git merge TARGET_BRANCH_NAME</code> to merge the current branch's changes with the target
</li>
<li>Ex: <code data-trim data-noescape>git merge remote/master</code> to merge with remote's master.</li>
</ul>
</section>
<section data-transition="convex">
<h2>Conflicts</h2>
<ul>
<li>
<code data-trim data-noescape>git status</code> indicates which files have conflicting changes between branches of the merge
</li>
<li>Markers:
<ul>
<li>Their code: <code><<<<HEAD</code></li>
<li>Separator: <code>====</code></li>
<li>Your code: <code>>>>>BRANCH_NAME</code></li>
</ul>
</li>
</ul>
</section>
<section data-transition="convex">
<h2>Rebasing</h2>
<ul>
<li>Add commits in a linear fashion (different from the date of committing)</li>
<li>
Use <code data-trim data-noescape>git rebase TARGET_BRANCH_NAME</code> to merge the current branch's changes with the target
</li>
<li>Ex: <code data-trim data-noescape>git rebase remote/master</code> to merge with remote's master.</li>
<li>
For added visualization and interaction in the process you can use <code data-trim data-noescape>git rebase -i TARGET_BRANCH_NAME</code>
</li>
</ul>
</section>
<section data-transition="convex">
<h2>Undoing Commits (from safest)</h2>
<ul>
<li>
<code data-trim data-noescape>git revert</code> creates a new commit that removes all the changes from the given commit
</li>
<li><code data-trim data-noescape>git reset</code></li>
<li><code data-trim data-noescape>git commit-amend</code> changes commit message</li>
<li><code data-trim data-noescape>git cherry-pick</code></li>
</ul>
<p>Be careful when changing commit IDs of commits on remote repositories</p>
</section>
</div>
</div>
<script src="js/reveal.js"></script>
<script>
Reveal.initialize();
</script>
</body>
</html>