Skip to content

Commit 3bba3c1

Browse files
authored
Merge pull request #9 from AdyGCode/dev
Dev
2 parents 1107f8d + 8a68e2f commit 3bba3c1

File tree

12 files changed

+342
-27
lines changed

12 files changed

+342
-27
lines changed
Lines changed: 1 addition & 0 deletions
Loading

.obsidian/plugins/obsidian-icon-folder/data.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"emojiStyle": "native",
77
"iconColor": null,
88
"recentlyUsedIcons": [
9+
"FasFolder",
910
"FasImage"
1011
],
1112
"recentlyUsedIconsSize": 5,
@@ -23,5 +24,7 @@
2324
"iconsInNotesEnabled": true,
2425
"iconIdentifier": ":"
2526
},
26-
"assets": "FasImage"
27+
"assets": "FasImage",
28+
"docs": "FasFolder",
29+
"theme": "FasFolder"
2730
}

.obsidian/workspace.json

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
"type": "split",
55
"children": [
66
{
7-
"id": "24d108f19bd80217",
7+
"id": "f854b54e1c2c8592",
88
"type": "tabs",
99
"children": [
1010
{
11-
"id": "08eecd3350f5b33e",
11+
"id": "e74c320159094cdf",
1212
"type": "leaf",
1313
"state": {
1414
"type": "markdown",
1515
"state": {
16-
"file": "docs/14-forking-over-code.md",
16+
"file": "docs/18-workflows.md",
1717
"mode": "source",
1818
"source": false
1919
}
@@ -85,7 +85,7 @@
8585
"state": {
8686
"type": "backlink",
8787
"state": {
88-
"file": "docs/14-forking-over-code.md",
88+
"file": "docs/18-workflows.md",
8989
"collapseAll": false,
9090
"extraContext": false,
9191
"sortOrder": "alphabetical",
@@ -102,7 +102,7 @@
102102
"state": {
103103
"type": "outgoing-link",
104104
"state": {
105-
"file": "docs/14-forking-over-code.md",
105+
"file": "docs/18-workflows.md",
106106
"linksCollapsed": false,
107107
"unlinkedCollapsed": true
108108
}
@@ -125,7 +125,7 @@
125125
"state": {
126126
"type": "outline",
127127
"state": {
128-
"file": "docs/14-forking-over-code.md"
128+
"file": "docs/18-workflows.md"
129129
}
130130
}
131131
}
@@ -147,12 +147,22 @@
147147
"table-editor-obsidian:Advanced Tables Toolbar": false
148148
}
149149
},
150-
"active": "08eecd3350f5b33e",
150+
"active": "e74c320159094cdf",
151151
"lastOpenFiles": [
152+
"assets/Pasted image 20240314154647.png",
153+
"assets/Pasted image 20240314154551.png",
154+
"docs/15-diffs.md",
155+
"assets/diff-difference.png",
156+
"assets/diff-hunk-headers.png",
157+
"assets/diff-header.png",
158+
"docs/18-workflows.md",
159+
"docs/14-forking-over-code.md",
160+
"assets/Pull-Request-Practice.md",
161+
"assets/collaboration.png",
162+
"docs/12-remotely-useful.md",
163+
"docs/98-command-line-extras.md",
152164
"CONTRIBUTE.md",
153165
"docs/98-command-line-extras.md",
154-
"docs/14-forking-over-code.md",
155-
"docs/15-workflows.md",
156166
"assets/pasted-image-20240314105028.png",
157167
"assets/pasted-image-20240314102512.png",
158168
"assets/front-cover.svg",
@@ -163,32 +173,22 @@
163173
"output",
164174
"docs/00-Back.md.md",
165175
"docs/00-Front.md.md",
166-
"assets/pasted-image-20240216114456.png",
167-
"assets/pasted-image-20240216124422.png",
168176
"docs/99-references-and-resources.md",
169177
"docs/08-status-add-commit.md",
170178
"docs/06-read-me.md",
171179
"ReadMe.md",
172180
"theme/style.css",
173181
"theme",
174182
"docs/13-why-hello-dolly.md",
175-
"docs/12-remotely-useful.md",
176183
"docs/11-merging-and-conflicts.md",
177184
"docs/10-shaking-the-tree.md",
178185
"docs/09-git-history.md",
179186
"docs/07-ignore-me.md",
180187
"docs/05-global-settings.md",
181188
"docs/04-git-started.md",
182189
"docs/02-getting-ready.md",
183-
"docs/03-repositories-and-folders.md",
184-
"docs/01-what-is-version-control.md",
185190
"docs",
186191
"assets/brave_dWSQwZYc3F.mp4",
187-
"assets/2024-03-01_15_03_52-AdyGCode_git-remote-demo-ii-Brave.png",
188-
"assets/2024-03-01_14_57_49-New-repository-Brave.png",
189-
"assets/2024-03-01_14_57_43-New-repository-Brave.png",
190-
"assets/2024-03-01_14_57_37-New-repository-Brave.png",
191-
"99-references-and-resources.md",
192192
"themes",
193193
"ReadMe.md~",
194194
"02-getting-ready.md~",

ReadMe.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ This ReadMe does not need a Table of contents, instead we provide links to each
3232
- [12 Remotely useful](docs/12-remotely-useful.md)
3333
- [13 Why, Hello Dolly](13-why-hello-dolly.md)
3434
- [14 Forking over code](docs/14-forking-over-code.md)
35-
- [15 Workflows](docs/15-workflows.md)
35+
- [15 Workflows](docs/18-workflows.md)
3636
-
3737
- ...
3838
- [99 References and Resources](docs/99-references-and-resources.md)

assets/Pull-Request-Practice.md

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
# Intro to PRs
2+
3+
![Illustrative image of people working together](collaboration.png)
4+
5+
You can use the following guide to learn how and why to create a pull request.
6+
7+
## What is a pull request?
8+
9+
A pull request is a way to suggest changes to a repository. When you create a pull request, you propose your changes and request that someone review and pull in your contribution and merge them into their branch. Pull requests show differences between the content from both branches and the changes are visible in the repository.
10+
11+
<!-- TODO: Add information on PRs and forks. -->
12+
13+
## Set up your environment
14+
15+
### Create a local copy of the repository
16+
17+
Copy the following file to a new Git repo.
18+
19+
```bash
20+
cd ~/source/repos
21+
git init my-first-pr
22+
cd my-first-pr
23+
cp ~/Downloads/README.md .
24+
```
25+
26+
**IMPORTANT:** Please ensure you continue working on the file copy and not the original.
27+
28+
### Create an empty repository on GitHub
29+
30+
1. Go to [GitHub](https://github.com) and sign in.
31+
2. In the upper-right corner of any page, select ``, and then select `New repository`.
32+
3. Name your repository `my-first-pr`.
33+
**IMPORTANT:** Do not initialize the repository with a `README`, `.gitignore`, or license.
34+
4. Note the name of your repository `URL` here: **<URL>**
35+
You'll need this information later.
36+
37+
### Add the remote repository
38+
39+
1. In the terminal, add the URL of the repository you created on GitHub as the remote repository.
40+
41+
```bash
42+
git remote add origin <URL>
43+
```
44+
45+
2. Check that the remote repository was added.
46+
47+
```bash
48+
git remote -v
49+
```
50+
51+
3. Consider why it does not provide a URL for pull, only `push` and `fetch`?
52+
53+
---
54+
55+
4. Push the local repository to the remote repository.
56+
57+
```bash
58+
git push -u origin main
59+
```
60+
61+
5. Refresh the GitHub page for your repository. You should see this `README.md` file.
62+
63+
### Why are pull requests called "Pull Requests"? (wrong answer)
64+
65+
Pull requests are so named basically because you are asking to _pull_ changes from a remote to your local repository. And that's because you have to ask permission to copy changes out of the repository, even if you have read access to that repository.
66+
67+
<!--TODO: This answer is SO wrong, I think we need to fix it! -->
68+
69+
### Create a local branch
70+
71+
You read the definition above, and you can't believe they got it this wrong. The name `Pull Request` can be misleading, but come on!
72+
73+
You decide to fix the definition above, but BEFORE you do that, you need to create a new branch to work on.
74+
75+
1. Create a new branch and switch to it.
76+
77+
```bash
78+
# Older style:
79+
git checkout -b fix/pr-definition
80+
# Or, newer style:
81+
git switch -c fix/pr-definition
82+
```
83+
84+
2. Edit this file and address the two TODO items in two separate commits.
85+
86+
```bash
87+
git commit -am "Add forks to the PR definition"
88+
git commit -am "Give correct reason to why PRs are named that"
89+
```
90+
91+
3. Check on GitHub whether the branch exists there or not. Does it? Why or why not?
92+
4. You may think it is because you haven't pushed to the branch yet, so go ahead and try to push the branch to the remote repository.
93+
94+
```bash
95+
git push
96+
# or in full
97+
git push origin fix/pr-definition
98+
```
99+
100+
You probably got a similar error to this:
101+
102+
```text
103+
fatal: The current branch fix/pr-definition has no upstream branch
104+
```
105+
106+
5. What does this error mean? Why did it happen? Git explains how to fix it by running a command that will:
107+
108+
1. Create a new branch on the remote repository with the same name as the local branch (if the remote branch doesn't already exist).
109+
2. Set the local branch to track the remote branch.
110+
3. Push the local branch to the remote repository.
111+
112+
7. Run the command that Git suggests to fix the error. There is also a shorthand for this command:
113+
114+
```bash
115+
git push -u origin fix/pr-definition
116+
```
117+
118+
7. Refresh the GitHub page for your repository. You should see the new branch there. GitHub will also suggest that you create a pull request. Do you see that?
119+
120+
### Create a pull request
121+
122+
1. Select `Compare & pull request`.
123+
2. Note that the base repository and compare branch are correct.
124+
3. Add a title and description for your pull request. Here is an example of a high-quality pull request description:
125+
126+
```markdown
127+
Title: Fix PR definition
128+
Description: This pull request fixes the definition of a pull request. It adds information about forks and corrects why pull requests are called "pull requests".
129+
```
130+
131+
4. Select `Create pull request`.
132+
133+
### Review and merge a pull request
134+
135+
1. Go to the `Pull requests` tab on the repository page.
136+
2. Select the pull request you created.
137+
3. Review the changes in the pull request. You can see the commits that were added to the branch. You can also view the changes in the `Files changed` tab.
138+
4. Add a comment to the pull request. Please feel free to ask for more information, suggest changes, or approve the pull request.
139+
5. Select `Merge pull request` to merge the changes into the `main` branch.
140+
141+
Notice that GitHub suggests that you delete the branch after merging. This is a good practice because it keeps your repository clean and easy to navigate. It is part of a Git workflow called `GitHub flow`.
142+
143+
### Optional: Fork someone else's repository and create a pull request
144+
145+
If you are doing this in class, you can fork the repository of the person sitting next to you. If you are doing this on your own, you can fork a friend's or colleague's repository.
146+
147+
When you fork their repo, examine their definition and try to improve on it, then create a pull request to suggest your changes on **their** repository.

assets/collaboration.png

445 KB
Loading

assets/diff-difference.png

43.1 KB
Loading

assets/diff-header.png

41.8 KB
Loading

assets/diff-hunk-headers.png

41 KB
Loading

docs/14-forking-over-code.md

Lines changed: 78 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,16 @@ In the contribution type of fork, you are using the fork almost like a branch.
4444

4545
The big thing about this is that you only need read permissions to the original repo to start working.
4646

47-
## Forking in the Enterprise
47+
# Forking in the Enterprise
4848

4949
Remember that forking is a GitHub feature. Other Git hosting solutions may have similar features.
5050

5151
Forking is common practice in open source development.
5252

5353

54-
## Comparing Forks v Branches
54+
# Comparing Forks v Branches
5555

56+
In an article by SSW in their "SSW Rules" they outline some of the fundamental differences:
5657

5758
| | Forks | Branches |
5859
| ----------------------------------------- | -------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
@@ -62,11 +63,11 @@ Forking is common practice in open source development.
6263
| **Scope of changes** | Typically involve significant changes | Typically involve smaller changes |
6364
| **Collaboration** | Used to develop ideas in isolation from the main team | Used to develop ideas that the main team is working on |
6465

65-
Based on SSW.Rules "Do you know when to create a fork vs a branch".
66+
> Based on SSW.Rules "Do you know when to create a fork vs a branch".
67+
>
68+
SSW.Rules. (n.d.). _Git - Do you know when to create a fork vs a branch?_ [online] Available at: https://www.ssw.com.au/rules/fork-vs-branch/ [Accessed 14 Mar. 2024].
6669

67-
SSW.Rules. (n.d.). _Git - Do you know when to create a fork vs a branch?_ [online] Available at: https://www.ssw.com.au/rules/fork-vs-branch/ [Accessed 14 Mar. 2024].
68-
69-
## How to Fork
70+
# How to Fork
7071

7172
Forking is done within the GitHub Web GUI.
7273

@@ -77,3 +78,74 @@ The basic process is:
7778
- Fork the repository (to your account)
7879
- Clone the repository to your local device
7980

81+
82+
83+
# Pull Requests
84+
85+
A pull request is a GitHub feature (with similar features in other git hosting).
86+
87+
A pull request proposes the target repo pulls from a secondary repo or branch. This is in place of pushing to a target repo (“production”) or merging to a production branch.
88+
89+
Thus “pull request” means:
90+
> request a pull from your branch instead of pushing to the target repo/branch
91+
92+
### Anatomy of a Pull Request
93+
94+
A pull request has the following features:
95+
- Has a target repo/branch <=> source repo/branch
96+
- Has a state: Open, Closed, Merged, Draft
97+
- Presents a moving Δ between the target and source
98+
- Contains an area to review and discuss, including in line comments
99+
- May be a trigger for automated checks and workflows
100+
101+
#### When combined with Protected Branches
102+
103+
GitHub allows you to specify that branches with a given name pattern are protected, this means that the branch may insist on:
104+
- A pull request before merge,
105+
- At least X reviewers or particular reviewers before merge is permitted
106+
- and other limitations on the request.
107+
108+
## How to Make a Pull Request
109+
110+
Imagine you created a fork or branch or both, and you think your changes are good enough for the main branch/repo... What should happen next?
111+
112+
There are two options:
113+
- Merge and see
114+
- Propose, discuss/review, then merge
115+
116+
### Merge and See
117+
118+
In “merge and see” your merge your changes and hope for the best.
119+
120+
This is not as crazy as it sounds since Git is meant to provide us with fail safes... What are the fail safes Git provide you with?
121+
122+
But:
123+
- You must have permissions to merge into the repo/branch
124+
- The code may not meet quality standards and organizational requirements
125+
- These may be “silent but deadly”...
126+
127+
A better option could be...
128+
129+
### Propose, Discuss/Review and Merge
130+
131+
Many people and organizations want to review proposed changes prior to merging. This is because the prospect of "bad code" becoming part of the software is not something anyone looks forward to.
132+
133+
The process of Propose, Review and Merge provides the following advantages:
134+
- Enhances quality
135+
- The process ensures that code that gets “mainlined” has been proofed.
136+
- Encourages collaboration
137+
- Any changes are not just the responsibility of the contributor of the code.
138+
- Reviewers and the owners of the project also have a stake in a change.
139+
- Improves security
140+
- We can have more authors than committers to the project.
141+
- These committers act as ‘gatekeepers’ who are the only ones allowed to merge a proposed set of a changes to given repos and branches.
142+
143+
## Exercise
144+
145+
In this repository you will find an exercise that you should download and follow. It is a single Markdown document with all the steps to practice pull requests. Download the [Pull Request Practice Read Me Markdown document](../assets/Pull-Request-Practice.md), and rename it `ReadMe.md`.
146+
147+
Open this file and follow the instructions.
148+
149+
To go with this exercise, there is an image, [collaboration.png](../assets/collaboration.png) to be downloaded and used in the exercise.
150+
151+
[13: Cloning](13-why-hello-dolly.md) | [15: Workflows](18-workflows.md)

0 commit comments

Comments
 (0)