@@ -8,10 +8,12 @@ how to use version control on an individual or a group project.
8
8
Imagine, for instance,
9
9
backing up and tracking your thesis,
10
10
or collaborating on writing a journal article
11
- with a colleague.
11
+ with a colleague,
12
+ or contributing to a Python library someone else has written.
12
13
13
14
We'll broadly follow the series of actions in this workflow:
14
15
16
+ * issue
15
17
* fork
16
18
* clone
17
19
* status
@@ -30,24 +32,57 @@ and we'll frequently refer to this diagram of git remotes:
30
32
![ git remotes] ( https://raw.githubusercontent.com/csdms/ivy/main/lessons/git/media/git-remotes-diagram.png " Git remotes ")
31
33
32
34
35
+ ## Issue
36
+
37
+ Say you're working with a Python library and you find a bug.
38
+ How can you communicate this problem to the library's author?
39
+ If the library is hosted on GitHub,
40
+ this is where an * issue* is used.
41
+ With an issue,
42
+ you can report a bug,
43
+ request a feature,
44
+ or just ask a question about a repository.
45
+ Issues are the primary way to communicate with a repository owner on GitHub.
46
+
47
+ An issue includes a title, a body,
48
+ and, optionally, a comment thread.
49
+ The title should be brief, yet descriptive.
50
+ The body is used to describe the issue;
51
+ it can written in [ Markdown] ( https://docs.github.com/en/github/writing-on-github/basic-writing-and-formatting-syntax ) ,
52
+ a simple markup language.
53
+ In the body,
54
+ you can also ` @ ` other GitHub users (e.g., ` @mcflugen ` )
55
+ to include them on the issue.
56
+ The comment thread is used to discuss the issue.
57
+ GitHub provides [ much more information] ( https://docs.github.com/en/issues/tracking-your-work-with-issues )
58
+ on writing issues.
59
+
60
+ Let's use the repository https://github.com/csdms/ivy-collaboration as an example.
61
+
62
+ 1 . Click the link above to go to the repository page on GitHub.
63
+ 1 . From the top left of the repository page, select the * Issues* button to create a new issue.
64
+
65
+ In the new issue,
66
+ request to be added as a contributor to the ` ivy-collaboration ` repository.
67
+ Create a title and add appropriate language to the body of the issue to make your request.
68
+
33
69
## Fork
34
70
35
- We'll start by forking a repository on GitHub.
36
- A * fork* is a copy of a repository, a * remote* , placed under your GitHub account.
71
+ After creating an issue,
72
+ we can propose a change to the example repository.
73
+
74
+ Start this process with a * fork* --a copy of a repository, a * remote* , placed under your GitHub account.
37
75
Forks are used for repositories where you don't have write access
38
76
(meaning you can view files, but not change them).
39
77
Note that forking is a GitHub, not a ` git ` , concept.
40
78
41
- Let's use the repository https://github.com/csdms/ivy-collaboration as an example.
42
-
43
- 1 . Go to the [ repository page] ( https://github.com/csdms/ivy-collaboration ) on GitHub.
44
- 1 . From the top right of the repository page, select the * Fork* button--you'll
45
- be asked where to create the fork; select your GitHub account.
79
+ From the top right of https://github.com/csdms/ivy-collaboration ,
80
+ select the * Fork* button--you'll be asked where to create the fork; select your GitHub account.
46
81
47
82
After the fork is created,
48
83
the path to the repository on GitHub will read
49
- ** [ username] /ivy-collaboration** instead of ** csdms/ivy-collaboration** ,
50
- where ** [ username] ** is your GitHub username,
84
+ ` [username]/ivy-collaboration ` instead of ` csdms/ivy-collaboration ` ,
85
+ where ` [username] ` is your GitHub username,
51
86
indicating your ownership of this copy of the repository.
52
87
53
88
@@ -61,9 +96,9 @@ As the name suggests,
61
96
a cloned repository is an identical, but separate,
62
97
copy of the current state of the original.
63
98
64
- On your computer, open a terminal and change to your ** Desktop ** directory:
99
+ On your computer, open a terminal and change to your home directory:
65
100
```
66
- $ cd ~/Desktop
101
+ $ cd
67
102
```
68
103
Note that this is a convenience; you can do the following steps anywhere on the filesystem.
69
104
@@ -73,14 +108,12 @@ The syntax for the `git clone` subcommand is
73
108
$ git clone [repository-url]
74
109
```
75
110
where the bracketed text should be replaced with the SSH URL of your new repository.
76
- You'll be prompted to enter the password for your SSH key.
111
+ You'll be prompted to enter the passphrase for your SSH key.
77
112
78
- The repository is cloned into the directory ** ivy-collaboration** .
113
+ The repository is cloned into the directory ` ivy-collaboration ` .
79
114
Change to it and view its contents:
80
115
```
81
116
$ cd ivy-collaboration
82
- $ pwd
83
- /Users/mpiper/Desktop/ivy-collaboration
84
117
$ ls
85
118
CONTRIBUTORS.md LICENSE README.md
86
119
```
@@ -155,7 +188,7 @@ use the `git checkout` subcommand
155
188
$ git checkout mdpiper/update-contributors
156
189
Switched to branch 'mdpiper/update-contributors
157
190
```
158
- You can verify that the new branch is current with ` git branch ` .
191
+ You can verify that the new branch is current with ` git branch ` or ` git status ` .
159
192
160
193
161
194
## Edit
@@ -164,16 +197,16 @@ Adding or editing content is typically where most of your time is spent
164
197
in a project.
165
198
In this example, however, it'll be trivial.
166
199
167
- Recall that the ** ivy-collaboration** repository
168
- has a file, ** CONTRIBUTORS.md** .
200
+ Recall that the ` ivy-collaboration ` repository
201
+ has a file, ` CONTRIBUTORS.md ` .
169
202
View the files in the repository:
170
203
```
171
204
$ ls
172
205
CONTRIBUTORS.md LICENSE README.md
173
206
```
174
207
With your favorite text editor,
175
- open ** CONTRIBUTORS.md**
176
- add your name to the list of contributors,
208
+ open ` CONTRIBUTORS.md `
209
+ and add your name to the list of contributors,
177
210
along with something interesting
178
211
(but not too interesting--this is a public repository).
179
212
Save the file.
@@ -245,8 +278,8 @@ to stage a subset of related changes to be grouped into a single commit.
245
278
To finalize the changes to the repository,
246
279
we * commit* them with ` git commit ` :
247
280
```
248
- $ git commit -m "Add an interesting fact to contributor list"
249
- [mdpiper/update-contributors 4c9565b] Add an interesting fact to contributor list
281
+ $ git commit -m "Add member to contributor list"
282
+ [mdpiper/update-contributors 4c9565b] Add member to contributor list
250
283
1 file changed, 1 insertion(+), 1 deletion(-)
251
284
```
252
285
@@ -317,7 +350,7 @@ remote:
317
350
To https://github.com/mdpiper/ivy-collaboration
318
351
* [new branch] mdpiper/update-contributors -> mdpiper/update-contributors
319
352
```
320
- You'll again be prompted to enter the password for your SSH key.
353
+ You'll again be prompted to enter the passphrase for your SSH key.
321
354
322
355
Note that the output from ` git push `
323
356
includes a link to create a * pull request* on GitHub.
@@ -327,22 +360,21 @@ and we'll create a pull request next.
327
360
328
361
## Pull request
329
362
330
- A * pull request* is a GitHub feature
331
- that allows you to argue why the changes that you've pushed to a remote
363
+ A * pull request* allows you to argue why the changes that you've pushed to a remote
332
364
deserve to be merged into that repository.
333
365
In a pull request,
334
366
you have to make a case to the owner of the repository
335
367
that your code improves on theirs.
336
368
337
- A pull request includes a title, a body,
369
+ Like an issue,
370
+ a pull request includes a title, a body,
338
371
and, optionally, a comment thread.
339
372
The title should be brief, yet descriptive,
340
373
and written as an imperative.
341
- The body is used to explain your changes
374
+ The body,
375
+ written in [ Markdown] ( https://docs.github.com/en/github/writing-on-github/basic-writing-and-formatting-syntax ) ,
376
+ is used to explain your changes
342
377
and to argue for their inclusion in the repository.
343
- To help make the text more descriptive,
344
- the body is written in [ Markdown] ( https://docs.github.com/en/github/writing-on-github/basic-writing-and-formatting-syntax ) ,
345
- a simple markup language.
346
378
In the body,
347
379
you can also ` @ ` other GitHub users (e.g., ` @BCampforts ` )
348
380
to include them on the pull request.
@@ -351,7 +383,7 @@ The comment thread is used to discuss the merits of the pull request.
351
383
GitHub provides [ much more information] ( https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests )
352
384
on pull requests.
353
385
354
- Argue well, and your contribution may be accepted by the repository owner!
386
+ Argue well and your contribution may be accepted by the repository owner!
355
387
356
388
357
389
## Merge
@@ -375,8 +407,9 @@ the *upstream* remote includes history not present in the *local* or *origin* re
375
407
We can * sync* these repositories in a few steps.
376
408
377
409
First,
378
- use the ` git remote ` subcommand to view what remotes are being tracked on your local machine :
410
+ use the ` git remote ` subcommand to view what remotes are being tracked by your local repository :
379
411
```
412
+ $ git remote -v
380
413
origin [email protected] :mdpiper/ivy-collaboration.git (fetch)
381
414
origin [email protected] :mdpiper/ivy-collaboration.git (push)
382
415
```
@@ -418,6 +451,10 @@ Finally, sync the *origin* remote by pushing the changes from your local reposit
418
451
$ git push origin main
419
452
```
420
453
454
+ All three repositories,
455
+ * local* , * origin* , and * upstream* ,
456
+ now contain the same information.
457
+
421
458
422
459
## Summary
423
460
@@ -428,7 +465,8 @@ For example,
428
465
all CSDMS products are open source.
429
466
If you find a problem in our software, documentation,
430
467
Jupyter Notebooks, etc.,
431
- please fix it and send us pull request!
468
+ please create an issue,
469
+ or just fix it and send us pull request!
432
470
You'll get credit for your contribution.
433
471
434
472
@@ -437,6 +475,7 @@ This table summarizes `git` and GitHub concepts covered in this section:
437
475
| Concept | Description
438
476
| ------------ | -----------
439
477
| repository | a storage area for files where history is tracked by version control
478
+ | issue | a tool for tracking work on GitHub
440
479
| fork | a repository copied from elsewhere on GitHub that exists under your GitHub account
441
480
| branch | a pointer to a timeline of commits to a repository
442
481
| current branch | the active repository branch accepting changes
0 commit comments