-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path4.1-advanced_github.qmd
127 lines (87 loc) · 4.07 KB
/
4.1-advanced_github.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
---
title: "Intro to `git`"
subtitle: "Block 4.1: Using GitHub to its Full Potential"
---
## Issues
- System to track tasks that still need to be done
- Allows for discussion
- When an issue is done, it is "closed"
::: {.fragment}
:::{.callout-tip}
Each issue get's its own number (e.g. #12). When you reference an issues commit number with a keyword like "fix", it will automatically be closed.
:::
:::
## Issues: Overview
![Overview of the issues page in a GitHub repository](images/screenshots/gh-issues.png)
::: attribution
Repository: <https://github.com/CorrelAid/datenguideR/>
:::
## Issues: Detailed View
![View of a single issue on GitHub](images/screenshots/gh-issue.png)
::: attribution
Repository: <https://github.com/CorrelAid/datenguideR/>
:::
## Forking
- You can easily copy public repositories into your own GitHub account, by `forking` them
- This way, you get your own remote version of the respository
- You can still contribute your changes back to the original repository
- The two repositories stay linked on GitHub
- This happens in GitHub not git
## Pull Requests (PRs)
- When collaborating with other people, it's often good to review each other's changes
- This is easiest done by using pull requests
- You *request* for someone to *pull* your changes
## Pull requests: Overview
![Overview of the pull requests page in a GitHub repository](images/screenshots/gh-prs.png)
::: attribution
Repository: <https://github.com/CorrelAid/datenguideR>
:::
## Pull requests: Detailed View
![View of a single pull request on GitHub](images/screenshots/gh-pr.png)
::: attribution
Repository: <https://github.com/CorrelAid/datenguideR>
:::
## Why Issues & Pull Requests are Necessary
![Right now, the VSCode GitHub repository has >5000 issues and almost 400 PRs](images/screenshots/gh-vscode.png)
::: attribution
Repository: <https://github.com/microsoft/vscode>
:::
## When Should you Start using Issues & PRs?
- Maybe your project doesn't need these features yet
- Often it makes sense to use pull requests even when collaborating with just a few people
- To avoid merge conflicts
- Also for reviewing each others changes
- Many companies require code reviews and using PRs
# Questions?
## Practical: Pull Requests by Yourself {background-color="black"}
1. Create a new branch `trying-out-pr`
- Make sure to also checkout that branch, you can check whether you're on it with `git status`
2. Add another entry to your `library.txt` (run any `git` command with `-h`)
3. Push the branch to GitHub
4. Create a pull request on GitHub
5. Merge the changes by creating a Pull Request
## Addendum: Checking out Remote Branches 🏝️
When collaborating, it can often be the case that you want to checkout a branch from a remote locally (e.g. one created by your colleague).
- First run `git fetch` to get branches
- Option 1: `git checkout --track <remote>/<branch>`
- Option 2: `git switch <branch>`
- Git switch will try to be smart here and guess that you want the remote branch ✨
## Practical: Collaborating via GitHub {background-color="black"}
1. Form groups of 2 - 3 people (we need exactly 10 teams total)
2. I will assign a number for each team.
3. Clone the repository and look up the topic based on your number
4. One person per team should create a new branch called `team-<your number>`, then `push` it to the hosted repo
## Practical: Collaborating via GitHub (using PRs) {background-color="black"}
1. Write a short section explaining your topic together.
2. Create a pull request to add your edits to the main repository. The title of the pull request should contain your team number and topic.
## Practical: Collaborating via GitHub (using PRs) {background-color="black"}
1. Review the pull requestion of the next team (by number) and provide feedback.
- Use the pull request to discuss
2. Approve the pull request when you're done and all changes are implemented.
3. Merge your edits into the repository.
## *End of Section* 🎉 {background-color="black"}
:::{.r-fit-text}
Any Questions?
:::
[[🏡 Back to Overview]](./index.html)
[[⏩️ Next Section]](./4.2-final_notes.html)