forked from mattmakai/fullstackpython.com
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsource-control.html
More file actions
313 lines (311 loc) · 18.3 KB
/
source-control.html
File metadata and controls
313 lines (311 loc) · 18.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
<!DOCTYPE html>
<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="Matt Makai">
<link rel="shortcut icon" href="theme/img/fsp-fav.png">
<title>Source Control - Full Stack Python</title>
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
<style>
.toc-indent {padding-left: 25px;}
.toc-more-indent {padding-left: 37px;}
</style>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-19910497-7', 'auto');
ga('send', 'pageview');
</script> </head>
<body>
<a href="https://github.com/makaimc/fullstackpython.github.com"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/a6677b08c955af8400f44c6298f40e7d19cc5b2d/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f677261795f3664366436642e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png"></a>
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="logo-header-section">
<a href="/" style="text-decoration: none; border: none;"><img src="theme/img/fsp-logo.png" height="52" width="52" class="logo-image" style="padding-top: 1px;" alt="Full Stack Python logo"></a>
<span class="logo-title"><a href="/">Full Stack Python</a></span>
</div>
</div>
</div><div class="row">
<div class="col-md-8">
<h1>Source control</h1>
<p>Source control, also known as <em>version control</em>, stores software code files
with a detailed history of every modification made to those files.</p>
<h2>Why is source control necessary?</h2>
<p>Version control systems allow developers to modify code without worrying
about permanently screwing something up. Unwanted changes can be easily rolled
back to previous working versions of the code. </p>
<p>Source control also makes team software development easier. One developer
can combine her code modifications with other developers' code through
<a href="http://en.wikipedia.org/wiki/Diff">diff</a> views that show line-by-line
changes then merge the appropriate code into the main code branch.</p>
<p>Version control is a necessity on all software projects regardless of
development time, codebase size or the programming language used. Every
project should immediately begin by using a version control system such
as Git or Mercurial.</p>
<h2>Source control during deployment</h2>
<p>Pulling code during a deployment is a potential way source control systems fit
into the deployment process. </p>
<p><img src="theme/img/app-source-control.png" width="100%" class="technical-diagram" alt="App deployment uses a server to pull from the source control system."></p>
<p>Note that some developers recommend deployment pipelines package the source
code to deploy it and never have a production environment touch a source
control system directly. However, for small scale deployments it's often
easiest to pull from source code when you're getting started instead of
figuring out how to wrap the Python code in a system installation package.</p>
<h2>Source control projects</h2>
<p>Numerous source control systems have been created over the past several
decades. In the past, proprietary source control software offered features
tailored to large development teams and specific project workflows. However,
open source systems are now used for version control on the largest and most
complicated software projects in existence. There's no reason why your project
should use anything other than an open source version control system in
today's Python development world. The two primary choices are:</p>
<ul>
<li>
<p><a href="http://git-scm.com/">Git</a> is a free and open source distributed version
control system.</p>
</li>
<li>
<p><a href="http://mercurial.selenic.com/">Mercurial</a> is similar to Git, also a free
and open source distributed version control system.</p>
</li>
</ul>
<h2>Hosted source control services</h2>
<p>Git and Mercurial can be downloaded and run on your own server. However,
it's easy and cheap to get started with a hosted version control service.
You can transition away from the service at a later time by moving your
repositories if your needs change. A couple of recommended hosted version
control services are:</p>
<ul>
<li>
<p><a href="https://github.com/">GitHub</a> is currently the most commonly used source
control platform for using Git.</p>
</li>
<li>
<p><a href="https://bitbucket.org/">BitBucket</a> provides free Git and Mercurial
repositories for open projects and private repositories for up to five
users. Users pay for hosting private repositories with more than five users.</p>
</li>
</ul>
<h2>General source control resources</h2>
<ul>
<li>
<p><a href="http://www.kalzumeus.com/2010/12/12/staging-servers-source-control-deploy-workflows-and-other-stuff-nobody-teaches-you/">Staging Servers, Source Control & Deploy Workflows, And Other Stuff Nobody Teaches You</a>
is a comprehensive overview by Patrick McKenzie of why you need source
control.</p>
</li>
<li>
<p><a href="https://blog.rainforestqa.com/2014-05-28-version-control-best-practices/">Version control best practices</a>
is a good write up of how to work with version control systems. The post is
part of an ongoing deployment guide written by the folks at
<a href="https://www.rainforestqa.com/">Rainforest</a>.</p>
</li>
<li>
<p>This lighthearted guide to the
<a href="http://www.flourish.org/2011/12/astonishments-ten-in-the-history-of-version-control/">ten astonishments in version control history</a>
is a fun way to learn how systems developed over the past several decades.</p>
</li>
<li>
<p><a href="http://betterexplained.com/articles/a-visual-guide-to-version-control/">A visual guide to version control</a>
is a detailed article with real-life examples for why version control is
necessary in software development.</p>
</li>
<li>
<p><a href="http://guides.beanstalkapp.com/version-control/intro-to-version-control.html">An introduction to version control</a>
shows the basic concepts behind version control systems.</p>
</li>
<li>
<p><a href="http://oss-watch.ac.uk/resources/versioncontrol">What Is Version Control? Why Is It Important For Due Diligence?</a>
explains the benefits and necessity of version control systems.</p>
</li>
<li>
<p><a href="http://git-scm.com/book/en/Getting-Started-About-Version-Control">About version control</a>
reviews the basics of distributed version control systems.</p>
</li>
</ul>
<h2>Git resources</h2>
<ul>
<li>
<p><a href="http://git-scm.com/book">Pro Git</a> is a free open source book that walks
through all aspects of using the version control system.</p>
</li>
<li>
<p><a href="http://wildlyinaccurate.com/a-hackers-guide-to-git">A Hacker's Guide to Git</a>
covers the basics as well as more advanced Git commands while explaining each
step along the way.</p>
</li>
<li>
<p><a href="http://mrchlblng.me/2014/09/practical-git-introduction/">A practical git introduction</a>
is exactly what the title says it is. This is a well written guide with
plenty of code snippets to get you up to speed with Git.</p>
</li>
<li>
<p><a href="http://gitready.com/">git ready</a> has a nice collection of blog posts based on
beginner, intermediate and advanced Git use cases.</p>
</li>
<li>
<p><a href="http://nvie.com/posts/a-successful-git-branching-model/">git-flow</a> details
a Git branching model for small teams.</p>
</li>
<li>
<p><a href="http://scottchacon.com/2011/08/31/github-flow.html">GitHub Flow</a> builds on
git-flow, goes over some of the issues that arise with it and presents a
few solutions to those problems.</p>
</li>
<li>
<p><a href="http://blog.endpoint.com/2014/05/git-workflows-that-work.html">Git Workflows That Work</a>
is a helpful post with diagrams to show how teams can create a Git workflow
that will help their development process.</p>
</li>
<li>
<p>"<a href="http://www.braintreepaymentsolutions.com/devblog/our-git-workflow">Our Git Workflow</a>"
by Braintree goes over how this payments company uses Git for development
and merging source code.</p>
</li>
</ul>
<h2>Source control learning checklist</h2>
<p><i class="fa fa-check-square-o"></i>
Pick a version control system. Git is recommended because on the web there
are a significant number of tutorials to help both new and advanced users.</p>
<p><i class="fa fa-check-square-o"></i>
Learn basic use cases for version control such as committing changes, rolling
back to earlier file versions and searching for when lines of code were
modified during development history.</p>
<p><i class="fa fa-check-square-o"></i>
Ensure your source code is backed up in a central repository. A central
repository is critical not only if your local development version is corrupted
but also for the deployment process.</p>
<p><i class="fa fa-check-square-o"></i>
Integrate source control into your deployment process in three ways. First,
pull the project source code from version control during deployments. Second,
kick off deployments when code is modified by using webhooks or polling on
the repository. Third, ensure you can roll back to a previous version if a
code deployment goes wrong.</p>
<h3>Now that your source code is versioned, what's next?</h3>
<div class="row">
<div class="col-md-4">
<div class="well select-next">
<a href="/deployment.html" class="btn btn-success btn-full"><i class="fa fa-share fa-2x"></i></a>
<p class="under-btn">
How do I deploy the code I've created for my web app?
</p>
</div>
</div>
<div class="col-md-4">
<div class="well select-next">
<a href="/web-analytics.html" class="btn btn-success btn-full"><i class="fa fa-dashboard fa-2x"></i></a>
</a>
<p class="under-btn">
I want to learn more about the users of my application.
</p>
</div>
</div>
<div class="col-md-4">
<div class="well select-next">
<a href="/api-integration.html" class="btn btn-success btn-full"><i class="fa fa-link fa-2x"></i></a>
<p class="under-btn">
How do I integrate external APIs into my web application?
</p>
</div>
</div>
</div> <div id="mc_embed_signup">
<form action="//mattmakai.us2.list-manage.com/subscribe/post?u=b7e774f0c4f05dcebbfee183d&id=b22335388d" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
<div id="mc_embed_signup_scroll">
<h4>Interested in major updates to this site or an alert when a complete Full Stack Python book with detailed example code is released? Sign up here and you'll an occasional email only when there's big news to report.</h4>
<div class="row">
<div class="col-md-9">
<input type="email" value="" name="EMAIL" class="email form-control" id="mce-EMAIL" placeholder="email address" required>
<div style="position: absolute; left: -5000px;"><input type="text" name="b_b7e774f0c4f05dcebbfee183d_b22335388d" tabindex="-1" value=""></div>
</div>
<div class="col-md-3">
<div class="clear"><input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="btn btn-success" style="font-family: 'Helvetica Neue';"></div>
</div>
</div>
</div>
</form>
</div>
</div>
<div class="col-md-offset-1 col-md-3" id="sidebar">
<div class="panel panel-success">
<div class="panel-heading">
<h3 class="panel-head"><a href="/table-of-contents.html" style="color: #fff;">Table of Contents</a></h3>
</div>
<div class="list-group">
<a href="/introduction.html" class="list-group-item smaller-item ">Introduction</a>
<a href="/why-use-python.html" class="list-group-item smaller-item ">Why Use Python?</a>
<a href="/development-environments.html" class="list-group-item smaller-item ">Development Environments</a>
<a href="/vim.html" class="list-group-item smaller-item ">Vim</a>
<a href="/best-python-resources.html" class="list-group-item smaller-item ">Best Python Resources</a>
<a href="/web-frameworks.html" class="list-group-item smaller-item ">Web Frameworks</a>
<a href="/django.html" class="list-group-item smaller-item ">Django</a>
<a href="/flask.html" class="list-group-item smaller-item ">Flask</a>
<a href="/bottle.html" class="list-group-item smaller-item ">Bottle</a>
<a href="/pyramid.html" class="list-group-item smaller-item ">Pyramid</a>
<a href="/morepath.html" class="list-group-item smaller-item ">Morepath</a>
<a href="/other-web-frameworks.html" class="list-group-item smaller-item ">Other Web Frameworks</a>
<a href="/web-design.html" class="list-group-item smaller-item ">Web Design</a>
<a href="/cascading-style-sheets.html" class="list-group-item smaller-item ">Cascading Style Sheets</a>
<a href="/javascript.html" class="list-group-item smaller-item ">JavaScript</a>
<a href="/websockets.html" class="list-group-item smaller-item ">WebSockets</a>
<a href="/web-application-security.html" class="list-group-item smaller-item ">Web Application Security</a>
<a href="/databases.html" class="list-group-item smaller-item ">Databases</a>
<a href="/no-sql-datastore.html" class="list-group-item smaller-item ">NoSQL Data Stores</a>
<a href="/application-programming-interfaces.html" class="list-group-item smaller-item ">Application Programming Interfaces</a>
<a href="/api-integration.html" class="list-group-item smaller-item ">API Integration</a>
<a href="/api-creation.html" class="list-group-item smaller-item ">API Creation</a>
<a href="/deployment.html" class="list-group-item smaller-item ">Deployment</a>
<a href="/servers.html" class="list-group-item smaller-item ">Servers</a>
<a href="/platform-as-a-service.html" class="list-group-item smaller-item ">Platform-as-a-service</a>
<a href="/operating-systems.html" class="list-group-item smaller-item ">Operating Systems</a>
<a href="/web-servers.html" class="list-group-item smaller-item ">Web Servers</a>
<a href="/wsgi-servers.html" class="list-group-item smaller-item ">WSGI Servers</a>
<a href="/source-control.html" class="list-group-item smaller-item active">Source Control</a>
<a href="/application-dependencies.html" class="list-group-item smaller-item ">Application Dependencies</a>
<a href="/static-content.html" class="list-group-item smaller-item ">Static Content</a>
<a href="/task-queues.html" class="list-group-item smaller-item ">Task Queues</a>
<a href="/configuration-management.html" class="list-group-item smaller-item ">Configuration Management</a>
<a href="/continuous-integration.html" class="list-group-item smaller-item ">Continuous Integration</a>
<a href="/logging.html" class="list-group-item smaller-item ">Logging</a>
<a href="/monitoring.html" class="list-group-item smaller-item ">Monitoring</a>
<a href="/web-analytics.html" class="list-group-item smaller-item ">Web Analytics</a>
<a href="/docker.html" class="list-group-item smaller-item ">Docker</a>
<a href="/caching.html" class="list-group-item smaller-item ">Caching</a>
<a href="/code-metrics.html" class="list-group-item smaller-item ">Code Metrics</a>
<a href="/what-full-stack-means.html" class="list-group-item smaller-item ">What "Full Stack" Means</a>
<a href="/change-log.html" class="list-group-item smaller-item ">Change Log</a>
<a href="/future-directions.html" class="list-group-item smaller-item ">Future Directions</a>
<a href="/about-author.html" class="list-group-item smaller-item ">About the Author</a>
</div>
</div>
<div class="panel panel-success">
<div class="panel-heading"><h3 class="panel-head">Source Control</h3></div>
<div class="panel-body">
Need more detailed tutorials and walkthroughs than you see here?
<a href="/email.html">Sign up for an email alert when that content is created.</a>
<hr/>
<a href="/">Full Stack Python</a> is an open book that explains
concepts in plain language and provides the most helpful resources
on those topics.
<hr/>
<a href="http://twitter.com/mattmakai">Matt Makai</a> built
this site with appreciated assistance from
<a href="https://github.com/makaimc/fullstackpython.github.com/pulls">pull requests</a>.
</div>
</div>
</div></div>
<hr/>
<div class="footer pull-right">
<a href="http://www.mattmakai.com/" class="underline">Matt Makai</a>
2015
</div>
</div>
<link href="theme/css/f.min.css" rel="stylesheet">
<link href="//netdna.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.css" rel="stylesheet">
</body>
</html>