Skip to content

Commit 59bc147

Browse files
Merge pull request #1 from astroDimitrios/clarify-roles
Clarify roles
2 parents 589f56d + a4561af commit 59bc147

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2466
-3
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,5 @@ vendor/
5353
.docker-vendor/
5454
Gemfile.lock
5555
.*history
56+
57+
.vscode

config.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ contact: '[email protected]'
5959

6060
# Order of episodes in your lesson
6161
episodes:
62+
- 01-working-practices.md
63+
- 02-branching.md
64+
- 03-feature-branch.md
65+
- 04-review.md
6266
- Break.md
6367
- End.md
6468

episodes/01-collab.md

+263
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,263 @@
1+
---
2+
title: Collaborating
3+
teaching: 25
4+
exercises: 0
5+
---
6+
7+
::::::::::::::::::::::::::::::::::::::: objectives
8+
9+
- Clone a remote repository.
10+
- Add collaborators to your repository.
11+
12+
::::::::::::::::::::::::::::::::::::::::::::::::::
13+
14+
:::::::::::::::::::::::::::::::::::::::: questions
15+
16+
- How can I use version control to collaborate with other people?
17+
18+
::::::::::::::::::::::::::::::::::::::::::::::::::
19+
20+
For the next step, get into pairs. One person will be the "Owner" and the other
21+
will be the "Collaborator". The goal is that the Collaborator add changes into
22+
the Owner's repository. We will switch roles at the end, so both persons will
23+
play Owner and Collaborator.
24+
25+
::::::::::::::::::::::::::::::::::::::::: callout
26+
27+
## Practicing By Yourself
28+
29+
If you're working through this lesson on your own, you can carry on by opening
30+
a second terminal window.
31+
This window will represent your partner, working on another computer. You
32+
won't need to give anyone access on GitHub, because both 'partners' are you.
33+
34+
::::::::::::::::::::::::::::::::::::::::::::::::::
35+
36+
The Owner needs to give the Collaborator access. In your repository page on GitHub, click the "Settings"
37+
button on the right, select "Collaborators", click "Add people", and
38+
then enter your partner's username.
39+
40+
![](fig/github-add-collaborators.png){alt='A screenshot of the GitHub Collaborators settings page, which is accessed by clicking "Settings" then "Collaborators"'}
41+
42+
To accept access to the Owner's repo, the Collaborator
43+
needs to go to [https://github.com/notifications](https://github.com/notifications)
44+
or check for email notification. Once there they can accept access to the Owner's repo.
45+
46+
Next, the Collaborator needs to download a copy of the Owner's repository to her
47+
machine. This is called "cloning a repo".
48+
49+
The Collaborator doesn't want to overwrite her own version of `climate`, so
50+
needs to clone the Owner's repository to a different location than her own
51+
repository with the same name.
52+
53+
To clone the Owner's repo into her `Desktop` folder, the Collaborator enters:
54+
55+
```bash
56+
$ git clone [email protected]:mo-eormerod/weather.git ~/Desktop/mo-eormerod-weather
57+
```
58+
59+
Replace 'mo-eormerod' with the Owner's username.
60+
61+
If you choose to clone without the clone path
62+
(`~/Desktop/mo-eormerod-weather`) specified at the end,
63+
you will clone inside your own weather folder!
64+
Make sure to navigate to the `Desktop` folder first.
65+
66+
![](fig/github-collaboration.svg){alt='A diagram showing that "git clone" can create a copy of a remote GitHub repository, allowing a second person to create their own local repository that they can make changes to.'}
67+
68+
The Collaborator can now make a change in her clone of the Owner's repository,
69+
exactly the same way as we've been doing before:
70+
71+
```bash
72+
$ cd ~/Desktop/mo-eormerod-weather
73+
$ nano shipping-forecast.md
74+
$ cat shipping-forecast.md
75+
```
76+
77+
```output
78+
New high expected Dover 1028 by 0600 tomorrow.
79+
Low Trafalgar 1013 losing its identity
80+
```
81+
82+
```bash
83+
$ git add shipping-forecast.md
84+
$ git commit -m "Add in the shipping forecast"
85+
```
86+
87+
```output
88+
1 file changed, 2 insertion(+)
89+
create mode shipping-forecast.md
90+
```
91+
92+
Then push the change to the *Owner's repository* on GitHub:
93+
94+
```bash
95+
$ git push origin main
96+
```
97+
98+
```output
99+
Enumerating objects: 4, done.
100+
Counting objects: 4, done.
101+
Delta compression using up to 4 threads.
102+
Compressing objects: 100% (2/2), done.
103+
Writing objects: 100% (3/3), 306 bytes, done.
104+
Total 3 (delta 0), reused 0 (delta 0)
105+
To https://github.com/mo-eormerod/weather.git
106+
9272da5..29aba7c main -> main
107+
```
108+
109+
Note that we didn't have to create a remote called `origin`: Git uses this
110+
name by default when we clone a repository. (This is why `origin` was a
111+
sensible choice earlier when we were setting up remotes by hand.)
112+
113+
Take a look at the Owner's repository on GitHub again, and you should be
114+
able to see the new commit made by the Collaborator. You may need to refresh
115+
your browser to see the new commit.
116+
117+
::::::::::::::::::::::::::::::::::::::::: callout
118+
119+
## Some more about remotes
120+
121+
In this episode and the previous one, our local repository has had
122+
a single "remote", called `origin`. A remote is a copy of the repository
123+
that is hosted somewhere else, that we can push to and pull from, and
124+
there's no reason that you have to work with only one. For example,
125+
on some large projects you might have your own copy in your own GitHub
126+
account (you'd probably call this `origin`) and also the main "upstream"
127+
project repository (let's call this `upstream` for the sake of examples).
128+
You would pull from `upstream` from time to
129+
time to get the latest updates that other people have committed.
130+
131+
Remember that the name you give to a remote only exists locally. It's
132+
an alias that you choose - whether `origin`, or `upstream`, or `mo-eormerod` -
133+
and not something intrinstic to the remote repository.
134+
135+
The `git remote` family of commands is used to set up and alter the remotes
136+
associated with a repository. Here are some of the most useful ones:
137+
138+
- `git remote -v` lists all the remotes that are configured (we already used
139+
this in the last episode)
140+
- `git remote add [name] [url]` is used to add a new remote
141+
- `git remote remove [name]` removes a remote. Note that it doesn't affect the
142+
remote repository at all - it just removes the link to it from the local repo.
143+
- `git remote set-url [name] [newurl]` changes the URL that is associated
144+
with the remote. This is useful if it has moved, e.g. to a different GitHub
145+
account, or from GitHub to a different hosting service. Or, if we made a typo when
146+
adding it!
147+
- `git remote rename [oldname] [newname]` changes the local alias by which a remote
148+
is known - its name. For example, one could use this to change `upstream` to `mo-eormerod`.
149+
150+
151+
::::::::::::::::::::::::::::::::::::::::::::::::::
152+
153+
To download the Collaborator's changes from GitHub, the Owner now enters:
154+
155+
```bash
156+
$ git pull origin main
157+
```
158+
159+
```output
160+
remote: Enumerating objects: 4, done.
161+
remote: Counting objects: 100% (4/4), done.
162+
remote: Compressing objects: 100% (2/2), done.
163+
remote: Total 3 (delta 0), reused 3 (delta 0), pack-reused 0
164+
Unpacking objects: 100% (3/3), done.
165+
From https://github.com/mo-eormerod/weather
166+
* branch main -> FETCH_HEAD
167+
9272da5..29aba7c main -> origin/main
168+
Updating 9272da5..29aba7c
169+
Fast-forward
170+
shipping-forecast.md | 2 +
171+
1 file changed, 2 insertion(+)
172+
create mode 100644 shipping-forecast.md
173+
```
174+
175+
Now the three repositories (Owner's local, Collaborator's local, and Owner's on
176+
GitHub) are back in sync.
177+
178+
::::::::::::::::::::::::::::::::::::::::: callout
179+
180+
## A Basic Collaborative Workflow
181+
182+
In practice, it is good to be sure that you have an updated version of the
183+
repository you are collaborating on, so you should `git pull` before making
184+
our changes. The basic collaborative workflow would be:
185+
186+
- update your local repo with `git pull origin main`,
187+
- make your changes and stage them with `git add`,
188+
- commit your changes with `git commit -m`, and
189+
- upload the changes to GitHub with `git push origin main`
190+
191+
It is better to make many commits with smaller changes rather than
192+
of one commit with massive changes: small commits are easier to
193+
read and review.
194+
195+
196+
::::::::::::::::::::::::::::::::::::::::::::::::::
197+
198+
::::::::::::::::::::::::::::::::::::::: challenge
199+
200+
## Switch Roles and Repeat
201+
202+
Switch roles and repeat the whole process.
203+
204+
205+
::::::::::::::::::::::::::::::::::::::::::::::::::
206+
207+
::::::::::::::::::::::::::::::::::::::: challenge
208+
209+
## Review Changes
210+
211+
The Owner putheyd commits to the repository without giving any information
212+
to the Collaborator. How can the Collaborator find out what has changed with
213+
command line? And on GitHub?
214+
215+
::::::::::::::: solution
216+
217+
## Solution
218+
219+
On the command line, the Collaborator can use `git fetch origin main`
220+
to get the remote changes into the local repository, but without merging
221+
them. Then by running `git diff main origin/main` the Collaborator
222+
will see the changes output in the terminal.
223+
224+
On GitHub, the Collaborator can go to the repository and click on
225+
"commits" to view the most recent commits putheyd to the repository.
226+
227+
228+
229+
:::::::::::::::::::::::::
230+
231+
::::::::::::::::::::::::::::::::::::::::::::::::::
232+
233+
::::::::::::::::::::::::::::::::::::::: challenge
234+
235+
## Comment Changes in GitHub
236+
237+
The Collaborator has some questions about one line change made by the Owner and
238+
has some suggestions to propose.
239+
240+
With GitHub, it is possible to comment on the diff of a commit. Over the line of
241+
code to comment, a blue comment icon appears to open a comment window.
242+
243+
The Collaborator posts her comments and suggestions using the GitHub interface.
244+
245+
246+
::::::::::::::::::::::::::::::::::::::::::::::::::
247+
248+
::::::::::::::::::::::::::::::::::::::: challenge
249+
250+
## Version History, Backup, and Version Control
251+
252+
Some backup software can keep a history of the versions of your files. They also
253+
allows you to recover specific versions. How is this functionality different from version control?
254+
What are some of the benefits of using version control, Git and GitHub?
255+
256+
257+
::::::::::::::::::::::::::::::::::::::::::::::::::
258+
259+
:::::::::::::::::::::::::::::::::::::::: keypoints
260+
261+
- `git clone` copies a remote repository to create a local repository with a remote called `origin` automatically set up.
262+
263+
::::::::::::::::::::::::::::::::::::::::::::::::::

episodes/01-working-practices.md

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
title: Working Practices
3+
teaching: 10
4+
exercises: 0
5+
---
6+
7+
::::::::::::::::::::::::::::::::::::::: objectives
8+
9+
- Describe a simple development flow using git and GitHub.
10+
11+
::::::::::::::::::::::::::::::::::::::::::::::::::
12+
13+
:::::::::::::::::::::::::::::::::::::::: questions
14+
15+
- What does using git and GitHub look like in practice?
16+
17+
::::::::::::::::::::::::::::::::::::::::::::::::::
18+
19+
Good working practices help us avoid mistakes,
20+
keep our codebases secure,
21+
and help us write sustainable code.
22+
In this lesson we'll look at what good practice using
23+
git and GitHub might look like.
24+
25+
The process to develop new code with git and GitHub
26+
looks like this:
27+
28+
1. Open an Issue describing the feature or bug
29+
2. Create a branch to develop your changes on
30+
3. Make changes to your working copy
31+
4. Write tests
32+
5. Write documentation
33+
6. Open a Pull Request
34+
7. Review your changes
35+
8. Merge the Pull Request and close the Issue
36+
9. Tidy up your branches
37+
38+
## Issues
39+
40+
GitHub Issues (tickets) are where you plan and track work.
41+
You can assign individuals to Issues and label them with a
42+
relevant tag such as `bug` or `enhancement`.
43+
Before opening a new Issue check whether there is already
44+
one open for the feature or bug by using GitHub's search.
45+
46+
![](fig/github-issue.png){alt='A screenshot of a GitHub Issue.'}
47+
48+
::::::::::::::::::::::::::::::::::::::: challenge
49+
50+
## Creating an Issue
51+
52+
Practice opening up an Issue on your `weather` repository.
53+
Your Issue will be a feature request for the shipping forecast.
54+
55+
::::::::::::::::::::::::::::::::::::::::::::::::::
56+
57+
:::::::::::::::::::::::::::::::::::::::: keypoints
58+
59+
- Issues are used to track and plan work
60+
61+
::::::::::::::::::::::::::::::::::::::::::::::::::

0 commit comments

Comments
 (0)