Skip to content

Commit 7f0ab6b

Browse files
authored
Merge pull request #181 from alex-ball/patch-132
Improve optional fork-and-PR challenge: 1. Fix formatting of heading and introductory paragraph. 2. Explain motivation for this workflow. 3. Replace broken link with illustrated step-by-step instructions.
2 parents 9cd2048 + ddf8262 commit 7f0ab6b

File tree

4 files changed

+116
-16
lines changed

4 files changed

+116
-16
lines changed

episodes/05-github-pages.md

Lines changed: 116 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ If we now visit `https://some-librarian.github.io/hello-world/`,
7474
we should see the contents of the index.md file that created earlier.
7575
Usually it's available instantly, but it can take a few seconds and in the worst case a few minutes if GitHub are very busy.
7676

77-
::::::::::::::::::::::::::::::::::::::: challenge
77+
:::::::::::::::::::::::::::::::::::::::: challenge
7878

7979
## Challenge: Contributing to a page owned by someone else (slightly easier way)
8080

@@ -85,19 +85,21 @@ Pair up in groups of two (or more if needed) and do the exercises below together
8585

8686
2. Click on "Fork" in the upper right part of the screen to create a copy of the repository on your account. Once you have a fork > of your partner's repository, you can edit the files in your own fork directly.
8787

88+
![](fig/github-fork-button.png){alt="GitHub fork button"}
89+
8890
3. Click the "index.md" file, then click the edit pencil icon:
8991

90-
![](fig/github-edit-pencil.png){alt="GitHub edit pencil"}
92+
![](fig/github-edit-pencil.png){alt="GitHub edit pencil"}
9193

9294
4. Now is good chance to try some Markdown syntax.
93-
Try some of the examples at [Mastering Markdown](https://guides.github.com/features/mastering-markdown/).
95+
Try some of the examples at [Mastering Markdown][].
9496
You can preview how it will look before you commit changes.
9597

9698
5. Once you are ready to commit, enter a short commit message,
9799
select "Create a new branch for this commit and start a pull request"
98100
and press "Propose changes" to avoid commiting directly to the main branch.
99101

100-
![](fig/github-commit-pr.png){alt="Commit and create pull request"}
102+
![](fig/github-commit-pr.png){alt="Commit and create pull request"}
101103

102104
6. You can now go to the repository on your account and click "New Pull Request" button,
103105
where you can select base branches repositories, review the changes and add an additional
@@ -110,6 +112,8 @@ Pair up in groups of two (or more if needed) and do the exercises below together
110112
This whole process of making a fork and a pull request might seem a bit cumbersome.
111113
Try to think of why it was needed? And why it's called "pull request"?
112114

115+
[Mastering Markdown]: https://guides.github.com/features/mastering-markdown/
116+
113117
::::::::::::::: solution
114118

115119
## Solution
@@ -129,23 +133,119 @@ it's more practical to grant everyone access to commit directly instead.
129133

130134
::::::::::::::::::::::::::::::::::::::::::::::::::
131135

132-
> ## Optional challenge: Contributing to a page owned by someone else (slightly more complicated way)
133-
>
134-
> Instead of making edits on the GitHub website you can 'clone' the fork to your local machine
135-
> and work there.
136+
:::::::::::::::::::::::::::::::::::::::: challenge
137+
138+
## Optional challenge: Contributing to a page owned by someone else (slightly more complicated way)
139+
140+
Instead of making edits on the GitHub website
141+
you can 'clone' the fork to your local machine and work there.
142+
There are several reasons why you might want to do this:
143+
144+
- you need to move content from one file to another;
145+
- you need to make changes to several files at once;
146+
- you find it easier to work in your desktop software than in a web form.
147+
148+
Pair up in groups of two (or more if needed) and follow the steps below together.
149+
If you have already tackled the previous challenge,
150+
you can use the fork you created there and skip to step 3.
151+
152+
1. Go to [https://github.com/some-librarian/hello-world](https://github.com/some-librarian/hello-world),
153+
where "some-librarian" is the username of your exercise partner.
154+
155+
2. Click on "Fork" in the upper right part of the screen
156+
to create a copy of that repository on your account.
157+
As you already have your own `hello-world` repository,
158+
you will need to use a different name for it, such as `hello-world-1`.
159+
160+
3. In your own fork, click on the "Code" button in the upper right part of the screen
161+
and copy a link to your repository.
162+
Just like when you [connected your local repository to GitHub][ep3-connecting],
163+
make sure "SSH" is selected, so the link starts with `[email protected]:`.
164+
165+
![](fig/github-fork-clone.png){alt="GitHub code button and clone method selection"}
166+
167+
4. Go back to your shell terminal window.
168+
If you're in your own Git repository, use the `cd` command
169+
to come out of it:
170+
171+
```bash
172+
# To check where you are:
173+
$ pwd
174+
# To go up one directory:
175+
$ cd ..
176+
```
177+
178+
Change the following command to use the link you just copied
179+
and run it:
180+
181+
```bash
182+
$ git clone [email protected]:<your_github_username>/hello-world-1.git
183+
```
184+
185+
The `clone` command creates a directory on your computer containing
186+
the current state of the repository and its full version history.
136187

137-
::::::::::::::::::::::::::::::::::::::: challenge
188+
5. Enter the directory that Git just created:
138189

139-
Try following the rest of the steps in this guide under ["Time to Submit Your First PR"](https://www.thinkful.com/learn/github-pull-request-tutorial/Writing-a-Good-Commit-Message#Time-to-Submit-Your-First-PR).
190+
```bash
191+
$ cd hello-world-1
192+
```
193+
194+
6. Create a new branch to hold the changes you're about to make:
195+
196+
```bash
197+
$ git switch -c my-patch-1
198+
```
199+
200+
Here, `switch` tells Git to change the current branch,
201+
the `-c` tells Git you want to create a new branch,
202+
and `my-patch-1` is what it will be called.
203+
204+
7. Open up the `index.md` and start editing it.
205+
You could try some more examples from [Mastering Markdown][].
206+
207+
8. After saving the file, add it, commit it with a short message describing the change:
208+
209+
```bash
210+
$ git add index.md
211+
$ git commit -m "Add more Markdown examples"
212+
```
213+
214+
9. Push your new branch up to your fork on GitHub:
215+
216+
```bash
217+
$ git push origin my-patch-1
218+
```
219+
220+
10. Git will show you a message from GitHub containing a link
221+
for starting a new pull request:
222+
223+
```output
224+
remote:
225+
remote: Create a pull request for 'my-patch-1' on GitHub by visiting:
226+
remote: https://github.com/<your_github_username>/hello-world-1/pull/new/my-patch-1
227+
remote:
228+
```
229+
230+
You can visit that link in your browser, but if you go back to your fork in GitHib
231+
you will also see a button has appeared that says "Compare & pull request".
232+
You can click on that button instead if you prefer.
233+
234+
![](fig/github-pr-create.png){alt="GitHub compare and pull request button"}
235+
236+
11. The next screen lets you add a description to explain your changes to the repository owner,
237+
and change the title to make it clearer
238+
(this is especially useful if you make a single pull request for multiple commits).
239+
When you're ready, click on the "Create pull request" button.
240+
241+
12. Your partner should now see a pull request under the "Pull requests" tab
242+
and can accept ("Merge pull request") the changes there. Try this.
140243

141-
(If you followed step 1 and 2 in the previous challenge,
142-
you already have a fork and you can skip the creation of a new fork.
143-
Start instead at the section titled "Cloning a fork."
144-
You can submit multiple pull requests using the same fork.)
244+
[ep3-connecting]: 03-sharing.html#connecting-your-local-repository-to-the-github-repository
145245

146246
::::::::::::::::::::::::::::::::::::::::::::::::::
147247

148-
::::::::::::::::::::::::::::::::::::::: challenge
248+
:::::::::::::::::::::::::::::::::::::::: challenge
149249

150250
## Optional challenge: Adding an HTML page
151251

@@ -155,7 +255,7 @@ steps below are for working directly on GitHub:
155255

156256
1. To add a new file directly on GitHub, press the "Create new file" button.
157257

158-
![](fig/github-create-new-file.png){alt="Create new file on GitHub"}
258+
![](fig/github-create-new-file.png){alt="Create new file on GitHub"}
159259

160260
2. Name it 'test.html', add some HTML and click "Commit new file".
161261

16.4 KB
Loading

episodes/fig/github-fork-clone.png

56.2 KB
Loading

episodes/fig/github-pr-create.png

26.4 KB
Loading

0 commit comments

Comments
 (0)