-
Notifications
You must be signed in to change notification settings - Fork 2
/
git-intro.html
379 lines (257 loc) · 10.4 KB
/
git-intro.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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Git and Github — slides</title>
<link rel="stylesheet" href="static/basic.css" type="text/css" />
<link rel="stylesheet" href="static/styles.css" type="text/css" />
<link rel="stylesheet" href="static/single.css" type="text/css" />
<link rel="stylesheet" href="static/custom.css" type="text/css" />
<link rel="stylesheet" href="static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '2015.07.01',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="static/jquery.js"></script>
<script type="text/javascript" src="static/underscore.js"></script>
<script type="text/javascript" src="static/doctools.js"></script>
<script type="text/javascript" src="static/common.js"></script>
<script type="text/javascript" src="static/slides.js"></script>
<script type="text/javascript" src="static/sync.js"></script>
<script type="text/javascript" src="static/controller.js"></script>
<script type="text/javascript" src="static/init.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="top" title="slides" href="index.html" />
<link rel="next" title="Dr. Jekyll and Mr. Pelican" href="jekyll-pelican.html" />
<link rel="prev" title="Cloud Terminology" href="clouds.html" />
</head>
<body>
<section
id="slide_container"
class='slides layout-regular'>
<article class="slide level-1" id="git-and-github">
<h1>Git and Github</h1>
<p>An Introduction</p>
</article>
<article class="slide level-2" id="what-we-ll-cover">
<h2>What We'll Cover</h2>
<ul class="simple">
<li>What's Git</li>
<li>Using <code class="docutils literal"><span class="pre">git</span></code></li>
<li>More resources</li>
</ul>
</article>
<article class="slide level-2" id="first-things-first">
<h2>First Things First</h2>
<ul class="simple">
<li><a class="reference external" href="https://github.com/join">Make an account on github</a></li>
</ul>
</article>
<article class="slide level-2" id="why-bother">
<h2>Why Bother?</h2>
<div class="figure align-right">
<a class="reference internal image-reference" href="images/phd_final.gif"><img alt="images/phd_final.gif" src="images/phd_final.gif" style="height: 500px;" /></a>
</div>
<p>Image from
<a class="reference external" href="http://www.phdcomics.com/comics/archive.php?comicid=1531">PhD Comics</a></p>
</article>
<article class="slide level-2" id="better-options-version-control">
<h2>Better Options: Version Control</h2>
<ul>
<li><p class="first">Commit = Snapshot of part of your project's state</p>
</li>
<li><p class="first">Centralized (SVN, CVS) vs. Decentralized (Git, hg)</p>
</li>
<li><dl class="first docutils">
<dt>We'll look at Git today</dt>
<dd><ul class="first last simple">
<li>Easier to learn other VCS from Git</li>
<li>Widely used in the open source world</li>
</ul>
</dd>
</dl>
</li>
</ul>
</article>
<article class="slide level-2" id="git">
<h2>Git</h2>
<div class="figure align-left">
<a class="reference internal image-reference" href="images/Linus_Torvalds.jpeg"><img alt="images/Linus_Torvalds.jpeg" src="images/Linus_Torvalds.jpeg" style="height: 400px;" /></a>
</div>
<p>git, noun. Brit.informal.
1. an unpleasant or contemptible person.</p>
</article>
<article class="slide level-2" id="setting-up-git">
<h2>Setting up Git</h2>
<ul class="simple">
<li>Linux:</li>
</ul>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ sudo <span class="o">[</span>yum <span class="p">|</span> apt <span class="o">]</span> install git
</pre></div>
</div>
<ul class="simple">
<li>Windows & Mac: <a class="reference external" href="https://desktop.github.com/">https://desktop.github.com/</a></li>
</ul>
</article>
<article class="slide level-2" id="configs">
<h2>Configs</h2>
<dl class="docutils">
<dt>[user]</dt>
<dd>email = <a class="reference external" href="mailto:wyman.lucy%40gmail.com">wyman<span>.</span>lucy<span>@</span>gmail<span>.</span>com</a>
name = Lucy Wyman</dd>
<dt>[core]</dt>
<dd>editor = vim</dd>
<dt>[credential]</dt>
<dd>username = lucywyman</dd>
</dl>
</article>
<article class="slide level-2" id="using-git-locally">
<h2>Using Git Locally</h2>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ git init
<span class="c1"># Make your changes</span>
$ git status <span class="c1"># or git diff</span>
$ git add <filename>
$ git commit
$ git push origin <branchname>
</pre></div>
</div>
<ul class="simple">
<li>Undo things?
the <a class="reference external" href="http://git-scm.com/book/en/Git-Basics-Undoing-Things">git book</a> explains
well</li>
<li>What commits have I made lately?</li>
</ul>
<div class="highlight-none"><div class="highlight"><pre><span></span>$ git log
</pre></div>
</div>
</article>
<article class="slide level-2" id="what-not-to-do">
<h2>What Not To Do</h2>
<ul>
<li><p class="first"><strong>Don't delete the .git files</strong></p>
</li>
<li><p class="first">Avoid redundant copies of the same work in one revision</p>
</li>
<li><dl class="first docutils">
<dt>Don't make "oops, undoing that" commits.</dt>
<dd><ul class="first last simple">
<li>Use git commit --amend or git revert</li>
</ul>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt>Don't wait too long between commits</dt>
<dd><ul class="first last simple">
<li>You can squash them all together later</li>
</ul>
</dd>
</dl>
</li>
<li><p class="first">Don't commit secrets, and if you do <strong>change them</strong>. Git never forgets.</p>
</li>
</ul>
<p><a class="reference external" href="http://arstechnica.com/security/2013/01/psa-dont-upload-your-important-passwords-to-github/">http://arstechnica.com/security/2013/01/psa-dont-upload-your-important-passwords-to-github/</a></p>
</article>
<article class="slide level-2" id="git-exercise">
<h2>Git Exercise</h2>
<p>First create a git repository!</p>
<div class="highlight-none"><div class="highlight"><pre><span></span>$ mkdir my_python_app
$ cd my_python_app
$ git init
</pre></div>
</div>
<p>Git will do a one-time prompt for some basic information and then you have a
Git Repository! All code in this code can be tracked by git as a single
project.</p>
</article>
<article class="slide level-2" id="adding-code">
<h2>Adding Code</h2>
<p>Create and open a new file <code class="docutils literal"><span class="pre">script.py</span></code> with the following command:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">f</span><span class="p">(</span><span class="n">x</span><span class="p">):</span>
<span class="k">print</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="n">x</span><span class="p">)</span>
<span class="k">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s2">"__main__"</span><span class="p">:</span>
<span class="n">f</span><span class="p">(</span><span class="mi">5</span><span class="p">)</span>
</pre></div>
</div>
<p>Save this file and leave the text editor and tell git to track this code.</p>
<div class="highlight-none"><div class="highlight"><pre><span></span>$ git status
$ git add script.py
$ git commit -m "My first git commit!"
$ git status
$ git push origin master
$ git log
</pre></div>
</div>
</article>
<article class="slide level-2" id="cloning-a-repository">
<h2>Cloning a Repository</h2>
<p>Git also allows you to <code class="docutils literal"><span class="pre">clone</span></code> a remote repository to work on another
person's code. It's like downloading the entire project and it's git history.</p>
<div class="highlight-none"><div class="highlight"><pre><span></span>$ cd ~
$ git clone git@github.com:DevOpsBootcamp/tinsy-flask-app.git
$ cd tinsy-flask-app
$ ls
</pre></div>
</div>
<p>You have successfully clone a remote repository and can start modifying the
other person's code. Changes you make on your local version of this project
will not affect the original version you modified (although you can push
changes if you are allowed to do so by the original owner!)</p>
</article>
<article class="slide level-2" id="branches">
<h2>Branches</h2>
<p>Github allows you to 'branch' your codebase. This allows you to make changes
on a separate track without modifying the original codebse in the same
repository. Branches are preserved when you clone a remote repository.</p>
<div class="highlight-none"><div class="highlight"><pre><span></span>$ git checkout broken
$ python myapp.py
</pre></div>
</div>
<p>Now you can see your webapp doesn't work correctly when you try to access it in
the browser!</p>
<p>We can manually go in and fix it, or run a command to see what changed between
this version and the version in the 'master' branch.</p>
<div class="highlight-none"><div class="highlight"><pre><span></span>$ git diff master
</pre></div>
</div>
</article>
<article class="slide level-2" id="daily-workflow">
<h2>Daily workflow</h2>
<div class="figure align-right">
<a class="reference internal image-reference" href="images/gitflow.png"><img alt="images/gitflow.png" src="images/gitflow.png" style="height: 400px;" /></a>
</div>
<p>Pull -> Work -> Add changes -> Commit -> Push</p>
<p>Larger projects have more complex workflows</p>
</article>
<article class="slide level-2" id="github">
<h2>GitHub!</h2>
<div class="figure">
<img alt="images/octocat.jpg" src="images/octocat.jpg" />
</div>
<ul class="simple">
<li>Free online code storage</li>
<li>Easily share and collaborate on code</li>
<li>Great Git documentation</li>
<li>Easily findable source-code</li>
</ul>
</article>
<article class="slide level-2" id="other-resources">
<h2>Other Resources</h2>
<ul class="simple">
<li><a class="reference external" href="https://help.github.com">Github Documentation</a></li>
<li><a class="reference external" href="http://www.wei-wang.com/ExplainGitWithD3/#">Git Visualizations</a></li>
<li><a class="reference external" href="https://github.com/DevOpsBootcamp/tinsy-flask-app#now-what">Further tiny-flask-app exercises</a></li>
</ul>
</article>
</section>
<section id="slide_notes">
</section>
</body>
</html>