Added exercise 6

This commit is contained in:
Tom van Woudenberg 2024-12-13 18:05:31 +01:00
parent b33a7ae010
commit 3aa2059f0a
4 changed files with 32 additions and 2 deletions

View file

@ -20,7 +20,7 @@ Video available [here](https://youtu.be/nN3Oi_MVvF0)
![Create new repository](figures/create_new_repository.png)
3. You can choose for `Private` only if you've GitHub Pro, GitHub Team, GitHub Enterprise Cloud, or GitHub Enterprise Server. Otherwise, you won't be able to publish your TeachBook online.
3. You can choose for `Private` only if you've GitHub Pro, GitHub Team, GitHub Enterprise Cloud, or GitHub Enterprise Server. Otherwise, you won't be able to publish your TeachBook online. Furthermore, it prevents people from contributing to your book, making your book essentially 'closed' instead of 'open.
4. (Only required for private repositories:) Create a Personal Access Token (classic) with at least the scopes `repo`, `read:org` and `gist` as described in the [github documentation](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens), and add this token with the name `GH_PAT` as a `Repository secret` or `Organization secret` (`Settings` > `Secrets and variables` > `Actions` > `Repository secrets` or `Organization secrets`).

View file

@ -14,6 +14,7 @@ parts:
- file: exercises/003.md
- file: exercises/004.md
- file: exercises/005.md
- file: exercises/006.md
- file: references.md
- file: changelog.md
- file: credits.md

View file

@ -6,7 +6,7 @@ In [](./004.md) you created your own version of a book. But it would be a pity i
1. Go to your repository homepage (`https://github.com/<your_username>/<your_repo_name>`). Probably, it will have big yellow announcement saying {octicon}`git-branch;1em` `1-<your_issue_title> had recent pushes <some> minutes ago - Compare & Pull request`. We'll ignore that for now and do it manually.
2. Go to the pull request page on your repository homepage (`https://github.com/<your_username>/<your_repo_name>`) - {octicon}`git-pull-request;1em` and click `New pull request`
3. On {octicon}`git-compare;1em` make sure you point from your branch `1-<your_issue_title>` into `main`. So, `main` on the left, {octicon}`arrow-left;1em` and `1-<your_issue_title>` on the right. Main is the default name for the branch which has the most recent/stable version. The page should now show all the changes you made on the `1-<your_issue_title>`-branch. If there would be changes on the `main` branch in the meantime, they should show up here too.
3. On {octicon}`git-compare;1em` make sure you point from your branch `1-<your_issue_title>` into `main`. So, `main` on the left, {octicon}`arrow-left;1em`, and `1-<your_issue_title>` on the right. Main is the default name for the branch which has the most recent/stable version. The page should now show all the changes you made on the `1-<your_issue_title>`-branch. If there would be changes on the `main` branch in the meantime, they should show up here too.
4. Click `Create pull request` to start the process of moving your changes into the `main` branch. If there were changes on both branches which are conflicting, it will tell you there's a merge conflict. If you followed the steps until now, that shouldn't be the case. Solving those merge conflicts is topic for another exercise.
5. Add a title and description described the changes you made. This is done to give other people a summary of what has been changed.
6. Assign yourself to make clear that you feel responsible.

29
book/exercises/006.md Normal file
View file

@ -0,0 +1,29 @@
# Exercise 6: Contribute to the book of somebody else
So far you did everything on your own. However, book-editing would be really boring if it would always be like that. Let's team up with someone to see the potential of collaborative book editing using git! Therefore, you'll take the book of someone else and create your own version of that one. Unlike before, we cannot simply make a branch, because you don't have access to their repository. However, you can make a copy of the repository on your own account, which is called a fork. Let's use that and contribute back to your friend's repository at the end.
> Can you fork a book repository of someone else, make changes and contribute back?
1. Go to the repository you want to contribute to (`https://github.com/<your_friends_username>/<your_friends_repo_name>`) and add an issue to let people know you're working on something - {octicon}`issue-opened;1em` `Issues` - `New issue`. You did this in [](./004.md).
2. Go back to the home page of repository you want to contribute to (`https://github.com/<your_friends_username>/<your_friends_repo_name>`) and click {octicon}`repo-forked;1em``Fork` at the top right corner to create a copy of the repository under your GitHub account.
3. Choose yourself as an owner and click `Create fork`. In the new screen you should see the same repo but on your own account. Furthermore, it mentions `forked from <your_friends_username>/<your_friends_repo_name>`
4. Make some changes on the main branch of your forked repo.
5. Check the changes in the online book.
6. Go to the pull request page on your forked repository homepage (`https://github.com/<your_username>/<your_friends_repo_name>/pulls`) - {octicon}`git-pull-request;1em` and click `New pull request`.
7. On {octicon}`git-compare;1em` make sure you point from your repositories branch `head repository: <your_username>/<your_friends_repo_name>:compare: main` into the original repository `base repository: <your_friends_username>/<your_friends_repo_name> base:main`. This should be the case by default.
8. In the description, add some explanation which for your friend to understand what your changes includes. Furthermore, it's useful to add `Closes #<number_of_issue_created_in_step_1>` so that the pull request is linked to the issue.
9. Click `Create pull request`. On the next page you'll see that the pull request is created in your friends repository.
10. Your friend will get a notification, but it wouldn't hurt to ask the person to review your pull request. Your friend might have some feedback or will just accept it right away!
#### ROBERT, CAN YOU CONTINUE HERE?
```{admonition} Check your understanding
:class: note
Before moving on to the next exercise, make sure you understand the following:
- What is a fork and how does it differ from a branch?
- Why is it important to create an issue before starting to work on a contribution?
- How do you create a pull request from a forked repository to the original repository?
- What should you include in the description of a pull request?
- How can you ensure that your friend is aware of your pull request?
```