Repository navigation
Expand file tree
/
Copy pathfeature_branching.html
More file actions
359 lines (240 loc) · 14.3 KB
/
Copy pathfeature_branching.html
File metadata and controls
359 lines (240 loc) · 14.3 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
<!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>Feature Branching — Python 210 6.0 documentation</title>
<script type="text/javascript" src="../../_static/js/modernizr.min.js"></script>
<script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
<script src="../../_static/jquery.js"></script>
<script src="../../_static/underscore.js"></script>
<script src="../../_static/doctools.js"></script>
<script src="../../_static/language_data.js"></script>
<script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/javascript" src="../../_static/js/theme.js"></script>
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
<link rel="index" title="Index" href="../../genindex.html" />
<link rel="search" title="Search" href="../../search.html" />
</head>
<body class="wy-body-for-nav">
<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" style="background: #4b2e83" >
<a href="../../index.html">
<img src="../../_static/UWPCE_logo_full.png" class="logo" alt="Logo"/>
</a>
<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="../../topics/index.html">Introduction to Python</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../MultipleInheritance.html">15.1.1. Multiple Inheritance</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../../index.html">Python 210</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content style-external-links">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../../index.html">Docs</a> »</li>
<li>Feature Branching</li>
<li class="wy-breadcrumbs-aside">
<a href="../../_sources/modules/dev_environment/feature_branching.rst.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="feature-branching">
<h1>Feature Branching<a class="headerlink" href="#feature-branching" title="Permalink to this headline">¶</a></h1>
<div class="section" id="why-use-feature-branches">
<h2>Why use Feature Branches?<a class="headerlink" href="#why-use-feature-branches" title="Permalink to this headline">¶</a></h2>
<p>The idea is to give a clear, highly focused purpose to each branch,
which is why we call them feature branches. They represent specific
feature being added or in our case a single assignment.</p>
<p>When using feature branches you isolate your code from everything else,
and Pull Request becomes easier to review as they only contain one
thing. This also mean that you can work on multiple features (multiple
assignments) at the same time without effecting each other and being
able to have two separate clean PRs along side.</p>
<p>Keep in mind that in a more professional setting the “master” branch
represents production code and will be the cleanest most stable branch.</p>
<p>Below is what’s called “Network Graph” of git activity. This displays
best what happens with feature branches.</p>
<p>The black line represents master, the green represents my 1st feature
branch that got merged into master (you can see arrow goes to black
line), then I created second feature branch called “test2” (blue line)
and that also got merged into master.</p>
<p>So feature branches get branched off the main branch (master) at some
point in time, then you do some isolated work, then merge it back into
main branch. No commits to master will affect your work in your feature
branch while you’re in it.</p>
<a class="reference internal image-reference" href="../../_images/feature_branching_img1.png"><img alt="../../_images/feature_branching_img1.png" src="../../_images/feature_branching_img1.png" style="width: 643.5px; height: 321.0px;" /></a>
</div>
<div class="section" id="workflow">
<h2>Workflow<a class="headerlink" href="#workflow" title="Permalink to this headline">¶</a></h2>
<div class="section" id="feature-assignment-branch">
<h3>1. Feature / Assignment Branch<a class="headerlink" href="#feature-assignment-branch" title="Permalink to this headline">¶</a></h3>
<p>Below explains the process for creating your feature branch. You can
either use the command line or the UI.</p>
<div class="section" id="creating-feature-branch-via-command-line">
<h4>Creating feature branch via Command Line<a class="headerlink" href="#creating-feature-branch-via-command-line" title="Permalink to this headline">¶</a></h4>
<p>First make sure you’re on master and make sure you have the latest
changes</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>git checkout master
git pull
</pre></div>
</div>
<p>Next you will create a new branch (-b flag) based of master</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>git checkout -b <new_feature_branch_name>
</pre></div>
</div>
<p>Here is the full example:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>$ git checkout master
Already on <span class="s1">'master'</span>
Your branch is up to date with <span class="s1">'origin/master'</span>.
$ git pull
$ git checkout -b lesson1/assignment1
Switched to a new branch <span class="s1">'lesson1/assignment1'</span>
</pre></div>
</div>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>$ git branch
branch_name1
another_branch
* lesson1/assignment1 <------- The asterisk here indicates your current branch
master
</pre></div>
</div>
<p>That’s it. You are now on an isolated feature branch, do your work and
make commits to this branch. There should be no difference.. when you’re
ready to push your changes you would now push to your feature branch
instead of master:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>git push origin <new_feature_branch_name>
</pre></div>
</div>
</div>
<div class="section" id="creating-feature-branch-via-github-ui">
<h4>Creating feature branch via GitHub UI<a class="headerlink" href="#creating-feature-branch-via-github-ui" title="Permalink to this headline">¶</a></h4>
<p>Navigate to your forked GitHub repo and identify Branch dropdown:</p>
<a class="reference internal image-reference" href="../../_images/feature_branching_img2.png"><img alt="../../_images/feature_branching_img2.png" src="../../_images/feature_branching_img2.png" style="width: 335.0px; height: 281.0px;" /></a>
<p>Initially you should only see master branch listed. Within that dropdown
type the name of the new feature branch, for this example we will call
it <code class="docutils literal notranslate"><span class="pre">lesson1/assignment1</span></code></p>
<a class="reference internal image-reference" href="../../_images/feature_branching_img3.png"><img alt="../../_images/feature_branching_img3.png" src="../../_images/feature_branching_img3.png" style="width: 347.0px; height: 249.0px;" /></a>
<p>Once you start typing the name of the branch, and if it does not
currently exist, you will get a prompt to create new branch. Click into
highlighted area (colors may differ based on browser or theme) and now
you have a new branch!</p>
<p>Go into command line and check out this new branch:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>$ git pull
$ git checkout lesson1/assignment1
Switched to branch <span class="s1">'lesson1/assignment1'</span>
$ git branch
feature_branch
* lesson1/assignment1 <------- asterisk here indicates your current branch
master
$
</pre></div>
</div>
</div>
</div>
<div class="section" id="when-feature-work-is-complete">
<h3>2. When Feature Work is Complete<a class="headerlink" href="#when-feature-work-is-complete" title="Permalink to this headline">¶</a></h3>
<p>When you’re done working on your feature branch it is time to create a
Pull Request to get your changes into master branch (both main class
repo and fork)</p>
<div class="section" id="create-pr-into-main-repo">
<h4>Create PR into main repo<a class="headerlink" href="#create-pr-into-main-repo" title="Permalink to this headline">¶</a></h4>
<p>In GitHub UI navigate to Pull Requests and select New pull request
button, you should now see options for source/target and branches</p>
<a class="reference internal image-reference" href="../../_images/feature_branching_img4.png"><img alt="../../_images/feature_branching_img4.png" src="../../_images/feature_branching_img4.png" style="width: 1118.0px; height: 309.0px;" /></a>
<p>In the far right dropdown you will want to select your feature branch.
Create the PR.</p>
</div>
<div class="section" id="merge-your-feature-branch-into-your-forked-master-branch">
<h4>Merge your feature branch into <em>your forked</em> master branch<a class="headerlink" href="#merge-your-feature-branch-into-your-forked-master-branch" title="Permalink to this headline">¶</a></h4>
<div class="section" id="command-line">
<h5>Command Line<a class="headerlink" href="#command-line" title="Permalink to this headline">¶</a></h5>
<p>note that you can always verify you are in your forked version by
running the command below which should show URL of origin</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>git remote show origin
</pre></div>
</div>
<p>Now check out master and make sure it is up to date</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>git checkout master
git pull
</pre></div>
</div>
<p>Next merge your feature branch (in our example <code class="docutils literal notranslate"><span class="pre">lesson1/assignment1</span></code>
into master</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>git merge --no-ff lesson1/assignment1
</pre></div>
</div>
<p>Next you will be prompted to commit with pre-populated commit message,
then save and close.</p>
<p>Finish up with</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>git push origin master
</pre></div>
</div>
</div>
<div class="section" id="github-ui">
<h5>GitHub UI<a class="headerlink" href="#github-ui" title="Permalink to this headline">¶</a></h5>
<p>If you’re not comfortable with command line, it is very easy to do in
the GitHub UI!</p>
<p>Navigate to Pull Requests again, and press New Pull request button, you
will now select your fork on the far left with master branch, and your
feature branch on the far right.</p>
<a class="reference internal image-reference" href="../../_images/feature_branching_img5.png"><img alt="../../_images/feature_branching_img5.png" src="../../_images/feature_branching_img5.png" style="width: 534.0px; height: 214.0px;" /></a>
<p>Create your pull request, then merge it and delete feature branch.</p>
</div>
</div>
</div>
</div>
<div class="section" id="extensive-explanation-of-feature-branching">
<h2>Extensive Explanation of Feature Branching<a class="headerlink" href="#extensive-explanation-of-feature-branching" title="Permalink to this headline">¶</a></h2>
<p>It has been said that git is not a Revision Control System, but rather, a tool you can use to make a Revision Control System. What this means is that git provides a huge number of features for managing your source code, but you still need to decide how to use it for your particular project. This is often referred to as the git “workflow”. The “feature-branch” workflow is one such approach to managing a project.</p>
<p>Here are a couple nice references that explain the feature branching workflow:</p>
<p><a class="reference external" href="https://www.atlassian.com/git/tutorials/comparing-workflows/feature-branch-workflow">https://www.atlassian.com/git/tutorials/comparing-workflows/feature-branch-workflow</a></p>
<p><a class="reference external" href="https://blog.landscape.io/use-feature-branches-for-everything.html">https://blog.landscape.io/use-feature-branches-for-everything.html</a></p>
</div>
</div>
</div>
</div>
<footer>
<hr/>
<div role="contentinfo">
<p>
© Copyright 2020, University of Washington, Natasha Aleksandrova, Christopher Barker, Brian Dorsey, Cris Ewing, Christy Heaton, Jon Jacky, Maria McKinley, Andy Miles, Rick Riehle, Joseph Schilz, Joseph Sheedy, Hosung Song. Creative Commons Attribution-ShareAlike 4.0 license
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/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">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>