-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathgit_overview.html
More file actions
374 lines (270 loc) · 16.6 KB
/
Copy pathgit_overview.html
File metadata and controls
374 lines (270 loc) · 16.6 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
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>git Overview — Introduction To Python 1.3 documentation</title>
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<link rel="top" title="Introduction To Python 1.3 documentation" href="../index.html"/>
<link rel="up" title="Supplemental Materials" href="index.html"/>
<link rel="next" title="Installing Nano on Windows" href="install_nano_win.html"/>
<link rel="prev" title="Shell Customizations for Python Development" href="shell.html"/>
<script src="../_static/js/modernizr.min.js"></script>
</head>
<body class="wy-body-for-nav" role="document">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search">
<a href="../index.html" class="icon icon-home"> Introduction To Python
</a>
<div class="version">
1.3
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../session01.html">Session One: Introductions</a></li>
<li class="toctree-l1"><a class="reference internal" href="../session02.html">Session Two: gitHub, Functions, Booleans and Modules</a></li>
<li class="toctree-l1"><a class="reference internal" href="../session03.html">Session Three: Sequences, Iteration and String Formatting</a></li>
<li class="toctree-l1"><a class="reference internal" href="../session04.html">Session Four: Lists, Iteration, Strings, Dictionaries, Sets</a></li>
<li class="toctree-l1"><a class="reference internal" href="../session05.html">Session Five: Files, Streams & String IO</a></li>
<li class="toctree-l1"><a class="reference internal" href="../session06.html">Session Six: Exceptions, Testing and Advanced Argument Passing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../session07.html">Session Seven: Object Oriented Programming</a></li>
<li class="toctree-l1"><a class="reference internal" href="../session08.html">Session Eight: Object Oriented Programming 2</a></li>
<li class="toctree-l1"><a class="reference internal" href="../session09.html">Session Nine: Object Oriented Programming 3</a></li>
<li class="toctree-l1"><a class="reference internal" href="../session10.html">Session Ten: Functional Programming</a></li>
</ul>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../exercises/index.html">Exercises</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html">Supplemental Materials</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="python_learning_resources.html">Useful Python Learning Resources</a></li>
<li class="toctree-l2"><a class="reference internal" href="python_for_mac.html">Setting up your Mac for Python</a></li>
<li class="toctree-l2"><a class="reference internal" href="python_for_windows.html">Setting up Windows for Python</a></li>
<li class="toctree-l2"><a class="reference internal" href="python_for_linux.html">Setting Up Python For Linux</a></li>
<li class="toctree-l2"><a class="reference internal" href="virtualenv.html">Working with Virtualenv</a></li>
<li class="toctree-l2"><a class="reference internal" href="sublime_as_ide.html">Turning Sublime Text Into a Lightweight Python IDE</a></li>
<li class="toctree-l2"><a class="reference internal" href="shell.html">Shell Customizations for Python Development</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="">git Overview</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#a-graphical-tutorial">A Graphical Tutorial</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#a-picture-of-git">A Picture of git</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#other-resources">Other Resources</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="install_nano_win.html">Installing Nano on Windows</a></li>
<li class="toctree-l2"><a class="reference internal" href="unicode.html">Unicode</a></li>
<li class="toctree-l2"><a class="reference internal" href="unicode.html#mechanics">Mechanics</a></li>
<li class="toctree-l2"><a class="reference internal" href="unicode.html#basic-unicode-lab">Basic Unicode LAB</a></li>
<li class="toctree-l2"><a class="reference internal" href="packaging.html">Packages and Packaging</a></li>
<li class="toctree-l2"><a class="reference internal" href="packaging.html#distributing">Distributing</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../index.html">Introduction To Python</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../index.html">Docs</a> »</li>
<li><a href="index.html">Supplemental Materials</a> »</li>
<li>git Overview</li>
<li class="wy-breadcrumbs-aside">
<a href="../_sources/supplements/git_overview.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="git-overview">
<span id="supplement-git-states"></span><h1>git Overview<a class="headerlink" href="#git-overview" title="Permalink to this headline">¶</a></h1>
<div class="section" id="a-graphical-tutorial">
<h2>A Graphical Tutorial<a class="headerlink" href="#a-graphical-tutorial" title="Permalink to this headline">¶</a></h2>
<div class="section" id="a-picture-of-git">
<h3>A Picture of git<a class="headerlink" href="#a-picture-of-git" title="Permalink to this headline">¶</a></h3>
<div class="figure">
<a class="center reference internal image-reference" href="../_images/git_simple_timeline.png"><img alt="../_images/git_simple_timeline.png" class="center" src="../_images/git_simple_timeline.png" style="width: 80%;" /></a>
</div>
<div class="build container">
<p>A git repository is a set of points in time, with history showing where
you’ve been.</p>
<p>Each point has a <em>name</em> (here <em>A</em>, <em>B</em>, <em>C</em>) that uniquely identifies it,
called a <em>hash</em></p>
<p>The path from one point to the previous is represented by the <em>difference</em>
between the two points.</p>
</div>
<div class="figure">
<a class="center reference internal image-reference" href="../_images/git_head.png"><img alt="../_images/git_head.png" class="center" src="../_images/git_head.png" style="width: 75%;" /></a>
</div>
<div class="build container">
<p>Each point in time can also have a label that points to it.</p>
<p>One of these is <em>HEAD</em>, which always points to the place in the timeline
that you are currently looking at.</p>
</div>
<div class="figure">
<a class="center reference internal image-reference" href="../_images/git_master_branch.png"><img alt="../_images/git_master_branch.png" class="center" src="../_images/git_master_branch.png" style="width: 75%;" /></a>
</div>
<div class="build container">
<p>You may also be familiar with the label “master”.</p>
<p>This is the name that git automatically gives to the first <em>branch</em> in a
repository.</p>
<p>A <em>branch</em> is actually just a label that points to a specific point in
time.</p>
</div>
<div class="figure">
<a class="center reference internal image-reference" href="../_images/git_new_commit.png"><img alt="../_images/git_new_commit.png" class="center" src="../_images/git_new_commit.png" style="width: 75%;" /></a>
</div>
<div class="build container">
<p>When you make a <em>commit</em> in git, you add a new point to the timeline.</p>
<p>The HEAD label moves to this new point.</p>
<p>So does the label for the <em>branch</em> you are on.</p>
</div>
<div class="figure">
<a class="center reference internal image-reference" href="../_images/git_new_branch.png"><img alt="../_images/git_new_branch.png" class="center" src="../_images/git_new_branch.png" style="width: 75%;" /></a>
</div>
<div class="build container">
<p>You can make a new <em>branch</em> with the <code class="docutils literal"><span class="pre">branch</span></code> command.</p>
<p>This adds a new label to the current commit.</p>
<p>Notice that it <em>does not</em> check out that branch.</p>
</div>
<div class="figure">
<a class="center reference internal image-reference" href="../_images/git_checkout_branch.png"><img alt="../_images/git_checkout_branch.png" class="center" src="../_images/git_checkout_branch.png" style="width: 75%;" /></a>
</div>
<div class="build container">
<p>You can use the <code class="docutils literal"><span class="pre">checkout</span></code> command to switch to the new branch.</p>
<p>This associates the HEAD label with the <em>session01</em> label.</p>
<p>Use <code class="docutils literal"><span class="pre">git</span> <span class="pre">branch</span></code> to see which branch is <em>active</em>:</p>
<div class="highlight-python"><div class="highlight"><pre>$ git branch
master
* session01
</pre></div>
</div>
</div>
<div class="figure">
<a class="center reference internal image-reference" href="../_images/git_commit_on_branch.png"><img alt="../_images/git_commit_on_branch.png" class="center" src="../_images/git_commit_on_branch.png" style="width: 75%;" /></a>
</div>
<div class="build container">
<p>While it is checked out, new commits move the <em>session01</em> label.</p>
<p>Notice that HEAD is <em>always</em> the same as “where you are now”</p>
</div>
<p>You can use this to switch between branches and make changes in isolation.</p>
<div class="build container">
<div class="figure">
<a class="center reference internal image-reference" href="../_images/git_checkout_master.png"><img alt="../_images/git_checkout_master.png" class="center" src="../_images/git_checkout_master.png" style="width: 75%;" /></a>
</div>
<div class="figure">
<a class="center reference internal image-reference" href="../_images/git_new_commit_on_master.png"><img alt="../_images/git_new_commit_on_master.png" class="center" src="../_images/git_new_commit_on_master.png" style="width: 75%;" /></a>
</div>
</div>
<div class="build container">
<p>Branching allows you to keep related sets of work separate from each-other.</p>
<p>In class here, you can use it to do your exercises for each session.</p>
<p>Simply create a new branch for each session from your repository master
branch.</p>
<p>Do your work on that branch, and then you can issue a <strong>pull request</strong> in
github to have your work evaluated.</p>
<p>This is very much like how teams work in the “real world” so learning it
here will help you.</p>
<p>The final step in the process is merging your work.</p>
</div>
<p>The <code class="docutils literal"><span class="pre">merge</span></code> command allows you to <em>combine</em> your work on one branch with the
work on another.</p>
<div class="build container">
<p>It creates a new commit which reconciles the differences:</p>
<div class="figure">
<a class="center reference internal image-reference" href="../_images/git_merge_commit.png"><img alt="../_images/git_merge_commit.png" class="center" src="../_images/git_merge_commit.png" style="width: 75%;" /></a>
</div>
<p>Notice that this commit has <strong>two</strong> parents.</p>
</div>
<div class="build container">
<p>Sometimes when you <code class="docutils literal"><span class="pre">merge</span></code> two branches, you get <em>conflicts</em>.</p>
<p>This happens when the same file was changed in about the same place in two
different ways.</p>
<p>Often, git can work these types of things out on its own, but if not,
you’ll need to manually edit files to fix the problem.</p>
<p>You’ll be helped by the fact that git will tell you which files are in
conflict.</p>
<p>Just open those files and look for conflict markers:</p>
<blockquote>
<div><ul class="simple">
<li><<<<<<<<< <em>hash1</em> (stuff from the current branch)</li>
<li>========= (the pivot point between two branches’ content)</li>
<li>>>>>>>>>> <em>hash2</em> (stuff from the branch being merged)</li>
</ul>
</div></blockquote>
</div>
<p>Your job in fixing a conflict is to decide exactly what to keep.</p>
<p>You can (and should) communicate with others on your team when doing this.</p>
<p>Always remember to remove the conflict markers too. They are not syntactic
code in any language and will cause errors.</p>
<p>Once a conflict is resolved, you can <code class="docutils literal"><span class="pre">git</span> <span class="pre">add</span></code> the file back and then commit
the merge.</p>
</div>
</div>
<div class="section" id="other-resources">
<h2>Other Resources<a class="headerlink" href="#other-resources" title="Permalink to this headline">¶</a></h2>
<p class="left here are few good places to look for more info about using git"><strong>Pro git</strong></p>
<p class="left here are few good places to look for more info about using git">The semi-offical documentation – the first few chapters are worth going through:</p>
<p class="left here are few good places to look for more info about using git"><a class="reference external" href="https://git-scm.com/book/en">https://git-scm.com/book/en</a></p>
<p class="left here are few good places to look for more info about using git">** git Branching**</p>
<p class="left here are few good places to look for more info about using git">Interactive tutorial about branching – try it right in the browser!</p>
<p class="left here are few good places to look for more info about using git"><a class="reference external" href="http://pcottle.github.io/learnGitBranching/">http://pcottle.github.io/learnGitBranching/</a></p>
</div>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="install_nano_win.html" class="btn btn-neutral float-right" title="Installing Nano on Windows" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="shell.html" class="btn btn-neutral" title="Shell Customizations for Python Development" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
© Copyright 2014, Christopher Barker, Cris Ewing, .
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../',
VERSION:'1.3',
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="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/javascript" src="../_static/js/theme.js"></script>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.StickyNav.enable();
});
</script>
</body>
</html>