@@ -33,19 +33,19 @@ we will cover the Jupyter Git interface.
33
33
34
34
## Chapter learning objectives
35
35
36
- By the end of the chapter, readers will be able to:
37
-
38
- - Describe what version control is and why data analysis projects can benefit from it
39
- - Create a remote version control repository on GitHub
40
- - use Jupyter's Git version control tools for project versioning and collaboration:
41
- - clone a remote version control repository to create a local repository
42
- - commit changes to a local version control repository
43
- - push local changes to a remote version control repository
44
- - pull changes from a remote version control repository to a local version control repository
45
- - resolve merge conflicts
46
- - Give collaborators access to a remote GitHub repository
47
- - Communicate with collaborators using GitHub issues
48
- - Use best practices when collaborating on a project with others
36
+ By the end of the chapter, readers will be able to do the following :
37
+
38
+ - Describe what version control is and why data analysis projects can benefit from it.
39
+ - Create a remote version control repository on GitHub.
40
+ - Use Jupyter's Git version control tools for project versioning and collaboration:
41
+ - Clone a remote version control repository to create a local repository.
42
+ - Commit changes to a local version control repository.
43
+ - Push local changes to a remote version control repository.
44
+ - Pull changes from a remote version control repository to a local version control repository.
45
+ - Resolve merge conflicts.
46
+ - Give collaborators access to a remote GitHub repository.
47
+ - Communicate with collaborators using GitHub issues.
48
+ - Use best practices when collaborating on a project with others.
49
49
50
50
## What is version control, and why should I use it?
51
51
@@ -57,7 +57,7 @@ made to the analysis, projects tend to become messy.
57
57
This mess can have serious, negative repercussions on an analysis project,
58
58
including interesting results files that your code cannot reproduce,
59
59
temporary files with snippets of ideas that are forgotten or
60
- not easy to find, mind-boggling filenames that make it unclear which is
60
+ not easy to find, mind-boggling file names that make it unclear which is
61
61
the current working version of the file (e.g., ` document_final_draft_final.txt ` ,
62
62
` to_hand_in_final_v2.txt ` , etc.), and more.
63
63
@@ -66,7 +66,7 @@ means that most of the time, the final version of the analysis that is
66
66
shared with the audience is only a fraction of what was explored during
67
67
the development of that analysis.
68
68
Changes in data visualizations and modeling approaches,
69
- as well as some negative results are often not observable from
69
+ as well as some negative results, are often not observable from
70
70
reviewing only the final, polished analysis.
71
71
The lack of observability of these parts of the analysis development
72
72
can lead to others repeating things that did not work well,
@@ -107,16 +107,16 @@ discuss issues and bugs, and distribute your final product.
107
107
For both of these items, there is a wide variety of choices.
108
108
In this textbook we'll use Git for version control,
109
109
and GitHub for repository hosting,
110
- because both are currently the most widely- used platforms.
110
+ because both are currently the most widely used platforms.
111
111
In the
112
- [ additional resources section at the end of the chapter] ( vc-add-res )
112
+ additional resources section at the end of the chapter,
113
113
we list many of the common version control systems
114
114
and repository hosting services in use today.
115
115
116
116
> ** Note:** Technically you don't * have to* use a repository hosting service.
117
117
> You can, for example, version control a project
118
- > that is stored only in a folder on your computer -
119
- > never sharing it on a repository hosting service.
118
+ > that is stored only in a folder on your computer& mdash ; never
119
+ > sharing it on a repository hosting service.
120
120
> But using a repository hosting service provides a few big benefits,
121
121
> including managing collaborator access permissions,
122
122
> tools to discuss and track bugs,
@@ -128,7 +128,7 @@ and repository hosting services in use today.
128
128
129
129
## Version control repositories
130
130
131
- Typically when we put a data analysis project under version control,
131
+ Typically, when we put a data analysis project under version control,
132
132
we create two copies of the repository \index{repository} (Figure \@ ref(fig: vc1-no-changes )).
133
133
One copy we use as our primary workspace where we create, edit, and delete files.
134
134
This copy is commonly referred to as \index{repository!local} the ** local repository** . The local
@@ -154,7 +154,7 @@ a version of the project. These records are \index{git!commit} called **commits
154
154
are a snapshot of the file contents as well
155
155
metadata about the repository at that time the record was created (who made the
156
156
commit, when it was made, etc.). In the local and remote repositories shown in
157
- Figure \@ ref(fig: vc1-no-changes ), there are two commits represented as grey
157
+ Figure \@ ref(fig: vc1-no-changes ), there are two commits represented as gray
158
158
circles. Each commit can be identified by a
159
159
human-readable ** message** , which you write when you make a commit, and a
160
160
** commit hash** that Git automatically adds for you.
@@ -177,7 +177,7 @@ two of these shortened hashes, one for each commit: `Daa29d6` and `884c7ce`.
177
177
178
178
## Version control workflows
179
179
180
- When you work in a local version controlled repository, there are generally three additional
180
+ When you work in a local version- controlled repository, there are generally three additional
181
181
steps you must take as part of your regular workflow. In addition to
182
182
just working on files&mdash ; creating,
183
183
editing, and deleting files as you normally would&mdash ; you must:
@@ -240,7 +240,7 @@ you need \index{git!push} to **push** (i.e., send) those commits back to GitHub
240
240
the history in the remote repository (i.e., GitHub) to match what you have in your
241
241
local repository. Now when collaborators interact with the remote repository, they will be able
242
242
to see the changes you made. And you can also take comfort in the fact that your work is now backed
243
- up on the cloud!
243
+ up in the cloud!
244
244
245
245
``` {r vc5-push, fig.cap = 'Pushing the commit to send the changes to the remote repository on GitHub.', fig.retina = 2, out.width="100%"}
246
246
image_read("img/vc5-push.png") |>
@@ -306,8 +306,8 @@ Before you can create remote repositories on GitHub,
306
306
you will need a GitHub account; you can sign up for a free account
307
307
at [ https://github.com/ ] ( https://github.com/ ) .
308
308
Once you have logged into your account, you can create a new repository to host
309
- your project by clicking on the "+" icon in the upper right
310
- hand corner, and then on "New Repository," as shown in
309
+ your project by clicking on the "+" icon in the upper right-hand
310
+ corner, and then on "New Repository," as shown in
311
311
Figure \@ ref(fig: new-repository-01 ).
312
312
313
313
(ref: new-repository-01 ) New repositories on GitHub can be created by clicking on "New Repository" from the + menu.
@@ -319,7 +319,7 @@ image_read("img/version_control/new_repository_01.png") |>
319
319
image_flop()
320
320
```
321
321
322
- Repositories can be setup with a variety of configurations, including a name,
322
+ Repositories can be set up with a variety of configurations, including a name,
323
323
optional description, and the inclusion (or not) of several template files.
324
324
One of the most important configuration items to choose is the visibility to the outside world,
325
325
either public or private. * Public* repositories \index{repository!public} can be viewed by anyone.
@@ -330,7 +330,7 @@ To get started with a *public* repository having a template `README.md` file, ta
330
330
following steps shown in Figure \@ ref(fig: new-repository-02 ):
331
331
332
332
1 . Enter the name of your project repository. In the example below, we use ` canadian_languages ` . Most repositories follow a similar naming convention involving only lowercase letter words separated by either underscores or hyphens.
333
- 2 . Choose an option for the privacy of your repository
333
+ 2 . Choose an option for the privacy of your repository.
334
334
3 . Select "Add a README file." This creates a template ` README.md ` file in your repository's root folder.
335
335
4 . When you are happy with your repository name and configuration, click on the green "Create Repository" button.
336
336
@@ -355,7 +355,7 @@ image_read("img/version_control/new_repository_03.png") |>
355
355
### Editing files on GitHub with the pen tool
356
356
357
357
The pen tool \index{GitHub!pen tool} can be used to edit existing plain text files. When you click on
358
- the pen tool the file will be opened in a text box where you can use your
358
+ the pen tool, the file will be opened in a text box where you can use your
359
359
keyboard to make changes (Figures \@ ref(fig: pen-tool-01 ) and \@ ref(fig: pen-tool-02 )).
360
360
361
361
``` {r pen-tool-01, fig.cap = 'Clicking on the pen tool opens a text box for editing plain text files.', fig.retina = 2, out.width="100%"}
@@ -399,8 +399,8 @@ image_read("img/version_control/pen-tool_03.png") |>
399
399
### Creating files on GitHub with the "Add file" menu
400
400
401
401
The "Add file" menu \index{GitHub!add file} can be used to create new plain text files and upload files
402
- from your computer. To create a new plain text file, click the "Add file" drop
403
- down menu and select the "Create new file" option
402
+ from your computer. To create a new plain text file, click the "Add file"
403
+ drop- down menu and select the "Create new file" option
404
404
(Figure \@ ref(fig: create-new-file-01 )).
405
405
406
406
``` {r create-new-file-01, fig.cap = 'New plain text files can be created directly on GitHub.', fig.retina = 2, out.width="100%"}
@@ -420,7 +420,7 @@ Note that GitHub understands and renders `.md` files \index{markdown} using a
420
420
very similar to Jupyter notebooks, so the "Preview" tab is especially helpful
421
421
for checking markdown code correctness.
422
422
423
- ``` {r create-new-file-02, fig.cap = 'New plain text files require a filename in the text box circled in red, and file content entered in the larger text box (red arrow).', fig.retina = 2, out.width="100%"}
423
+ ``` {r create-new-file-02, fig.cap = 'New plain text files require a file name in the text box circled in red, and file content entered in the larger text box (red arrow).', fig.retina = 2, out.width="100%"}
424
424
image_read("img/version_control/create-new-file_02.png") |>
425
425
image_flop() |>
426
426
image_crop("3584x1300") |>
@@ -436,10 +436,10 @@ image_read("img/version_control/create-new-file_03.png") |>
436
436
```
437
437
438
438
You can also upload files that you have created on your local machine by using
439
- the "Add file" drop down menu and selecting "Upload files"
439
+ the "Add file" drop- down menu and selecting "Upload files"
440
440
(Figure \@ ref(fig: upload-files-01 )).
441
441
To select the files from your local computer to upload, you can either drag and
442
- drop them into the grey box area shown below, or click the "choose your files"
442
+ drop them into the gray box area shown below, or click the "choose your files"
443
443
link to access a file browser dialog. Once the files you want to upload have
444
444
been selected, click the green "Commit changes" button at the bottom of the
445
445
page (Figure \@ ref(fig: upload-files-02 )).
@@ -548,11 +548,11 @@ image_read("img/generate-pat_03.png")
548
548
Now that we have everything we need for authentication,
549
549
the next step is to * clone* the \index{git!clone} remote repository on GitHub
550
550
to create a local repository, i.e., make a
551
- copy that knows where it was obtained from so that it knows where send/receive
551
+ copy that knows where it was obtained from so that it knows where to send/receive
552
552
new committed edits. In order to do this, first copy the URL from the HTTPS tab
553
- of the Code drop down menu on GitHub (Figure \@ ref(fig: clone-02 )).
553
+ of the Code drop- down menu on GitHub (Figure \@ ref(fig: clone-02 )).
554
554
555
- (ref: clone-02 ) The remote address (URL) corresponding to the location of the remote GitHub repository can be found in the green "Code" drop down menu.
555
+ (ref: clone-02 ) The remote address (URL) corresponding to the location of the remote GitHub repository can be found in the green "Code" drop- down menu.
556
556
557
557
``` {r clone-02, fig.cap = '(ref:clone-02)', fig.retina = 2, out.width="100%"}
558
558
image_read("img/version_control/clone_02.png") |>
@@ -743,7 +743,7 @@ image_read("img/version_control/add_collab_05.png") |>
743
743
image_crop("3584x1250")
744
744
```
745
745
746
- After this you should see your newly added collaborator listed under the
746
+ After this, you should see your newly added collaborator listed under the
747
747
"Manage access" tab. They should receive an email invitation to join the
748
748
GitHub repository as a collaborator. They need to accept this invitation
749
749
to enable write access.
@@ -835,7 +835,7 @@ The beginning of the merge
835
835
conflict is preceded by ` <<<<<<< HEAD ` and the end of the merge conflict is
836
836
marked by ` >>>>>>> ` . Between these markings, Git also inserts a separator
837
837
(` ======= ` ). The version of the change before the separator is your change, and
838
- the version that follows the separator was the change that existed on GitHub
838
+ the version that follows the separator was the change that existed on GitHub.
839
839
In Figure \@ ref(fig: merge-conflict-05 ), you can see that in your local repository
840
840
there is a line of code that calls ` scale_color_manual ` with three color values (` deeppink2 ` , ` cyan4 ` , and ` purple1 ` ).
841
841
It looks like your collaborator made an edit to that line too, except with different colors (to ` blue3 ` , ` red3 ` , and ` black ` )!
@@ -873,7 +873,7 @@ GitHub page, and they persist there even after the conversation is over and the
873
873
contrast to email, issues are not usually deleted). One issue thread is usually created
874
874
per topic, and they are easily searchable using GitHub's search tools. All
875
875
issues are accessible to all project collaborators, so no one is left out of
876
- the conversation. Finally, issues can be setup so that team members get email
876
+ the conversation. Finally, issues can be set up so that team members get email
877
877
notifications when a new issue is created or a new post is made in an issue
878
878
thread. Replying to issues from email is also possible. Given all of these advantages,
879
879
we highly recommend the use of issues for project-related communication.
@@ -898,7 +898,7 @@ image_read("img/version_control/issue_02.png") |>
898
898
```
899
899
900
900
Add an issue title (which acts like an email subject line), and then put the
901
- body of the message in the larger text box. Finally click "Submit new issue"
901
+ body of the message in the larger text box. Finally, click "Submit new issue"
902
902
to post the issue to share with others (Figure \@ ref(fig: issue-03 )).
903
903
904
904
``` {r issue-03, fig.cap = 'Dialog boxes and submission button for creating new GitHub issues.', fig.retina = 2, out.width="100%"}
0 commit comments