Skip to content

Commit 8bfe0e0

Browse files
authored
[Documentation:Developer] instructions for pushing to a fork (#603)
Adds documentation for how to pull, commit, & push to a PR made on a fork from an external contributor. --------- Co-authored-by: Barb Cutler <Barb Cutler>
1 parent 9f43687 commit 8bfe0e0

File tree

4 files changed

+123
-2
lines changed

4 files changed

+123
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
---
2+
title: How To Checkout and Commit to a PR from a Forked Repository
3+
category: Developer > Getting Started
4+
---
5+
6+
Contributors who are part of the Submitty organization on Github can
7+
make new branches on our Github repositories and should make PRs from
8+
a *branch directly within the Submitty repository*. External
9+
contributors cannot make new branches on the Submitty repositories.
10+
Instead, external contributors will clone/fork the Submitty repository
11+
and then make a PR from *a branch on their forked repository*.
12+
13+
It is simpler to review a PR made from a branch, and it is easy to
14+
make small revisions as needed and commit and push those changes to
15+
the branch. It is a little more work to do the same with a PR made
16+
from a fork, but it is still possible -- *assuming that the owner of
17+
the forked repository has granted the necessary permissions*. This
18+
allows multiple developers to collaborate and finalize a PR for
19+
merging to the main branch.
20+
21+
The instructions below are for command line use of git.
22+
23+
24+
1. First, from the PR on the Github website, find the name of the
25+
fork + branch name. It should be formatted something like this:
26+
```
27+
contributorusername:contributor_branch_name
28+
```
29+
30+
31+
2. Next, make a local branch on your computer in your working repository
32+
with the proposed code changes. Here are the command lines
33+
(substitute the fork & branch name we found above):
34+
35+
If you **are not** using ssh keys on git:
36+
```
37+
git checkout -b contributorusername-contributor_branch_name main
38+
git pull https://github.com/contributorusername/Submitty.git contributor_branch_name
39+
```
40+
41+
If you **are** using ssh keys on git:
42+
```
43+
git checkout -b contributorusername-contributor_branch_name main
44+
git pull [email protected]:contributorusername/Submitty.git contributor_branch_name
45+
```
46+
47+
48+
3. This has made a local branch named
49+
`contributorusername-contributor_branch_name`. Go ahead and test
50+
and review the PR and make code edits and new commits to your
51+
local branch as needed.
52+
53+
54+
55+
4. In order to push the changes to the contributor's fork (and the PR
56+
on Github from the fork), you will specify the upstream to be the
57+
contributor's fork:
58+
59+
If you **are not** using ssh keys on git:
60+
```
61+
git remote add upstream https://github.com/contributorusername/Submitty.git
62+
```
63+
64+
65+
If you **are** using ssh keys on git:
66+
```
67+
git remote add upstream [email protected]:contributorusername/Submitty.git
68+
```
69+
70+
71+
Confirm that the upstream was set:
72+
```
73+
git remote -v
74+
```
75+
76+
Which should print something like this if you **are not** using ssh keys on git:
77+
```
78+
origin https://github.com/Submitty/Submitty.git (fetch)
79+
origin https://github.com/Submitty/Submitty.git (push)
80+
upstream https://github.com/contributorusername/Submitty.git (fetch)
81+
upstream https://github.com/contributorusername/Submitty.git (push)
82+
```
83+
84+
Or this if you **are** using ssh keys on git:
85+
```
86+
origin [email protected]:Submitty/Submitty.git (fetch)
87+
origin [email protected]:Submitty/Submitty.git (push)
88+
upstream [email protected]:contributorusername/Submitty.git (fetch)
89+
upstream [email protected]:contributorusername/Submitty.git (push)
90+
```
91+
92+
93+
5. Now once you are finished with your code changes, first commit them to
94+
the local branch (named
95+
`contributorusername-contributor_branch_name`).
96+
97+
And then push them from your local branch to the external
98+
contributor's fork and update the PR on github:
99+
```
100+
git push upstream contributorusername-contributor_branch_name:contributor_branch_name
101+
```
102+
103+
*NOTE: If you encounter a permissions error, it is possible that the external
104+
contributor didn't grant access for collaboration on the branch.*
105+
106+
6. Confirm that you can see the changes on the Github website for the PR.
107+
108+
109+
---
110+
111+
See also [How to Make a Pull Request](make_a_pull_request) and
112+
[How to Review a Pull Request](review_a_pull_request).

_docs/developer/getting_started/make_a_pull_request.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Be sure to read the [Suggestions for New Developers](/developer/getting_started/
1818

1919

2020
2. Contributors from outside the Submitty GitHub organization should
21-
clone the repo on their own GitHub page, and create a branch with
21+
clone/fork the repo on their own GitHub page, and create a branch with
2222
the modifications to be included with this pull request (PR).
2323

2424
_**IMPORTANT NOTE**:_ Please grant write access to the Submitty
@@ -167,8 +167,11 @@ Be sure to read the [Suggestions for New Developers](/developer/getting_started/
167167
for specific reviewers.
168168
169169
170+
---
171+
170172
See also [How to Review a Pull Request](review_a_pull_request).
171173
174+
---
172175
173176
These guidelines drawn from:
174177

_docs/developer/getting_started/review_a_pull_request.md

+5
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ What do you need to do?
5353
Now you have a version of the code in a new branch on the main repo.
5454
Review the PR normally and delete the temporary branch when you are done
5555
56+
* If you need to make edits to a PR made from a branch in a forked
57+
repo, see:
58+
[How to Checkout and Commit to a Fork PR](commit_to_PR_from_fork)
59+
5660
5761
4. [Re-install the system](/developer/development_instructions/index)
5862
as necessary
@@ -108,5 +112,6 @@ What do you need to do?
108112
hopefully, in short order, approving that the code be merged into
109113
the main branch.
110114
115+
---
111116
112117
See also [How to Make a Pull Request](make_a_pull_request).

navtreedata.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,9 @@ var NAVTREE =
187187
[ "Getting Started", "/developer/getting_started/index", [
188188
[ "Overview", "/developer/getting_started/index", null ],
189189
[ "Project Ideas", "/developer/getting_started/project_ideas", null ],
190-
[ "Review a Pull Request", "/developer/getting_started/review_a_pull_request", null ],
191190
[ "Make a Pull Request", "/developer/getting_started/make_a_pull_request", null ],
191+
[ "Review a Pull Request", "/developer/getting_started/review_a_pull_request", null ],
192+
[ "Commit to PR from Fork", "/developer/getting_started/commit_to_PR_from_fork", null ],
192193
[ "Edit Submitty Documentation", "/developer/getting_started/edit_submitty_documentation", null ],
193194
[ "VM Install using Vagrant", "/developer/getting_started/vm_install_using_vagrant", [
194195
[ "Vagrant QEMU on Apple Silicon", "/developer/getting_started/vm_install_using_vagrant_apple_silicon", null ]

0 commit comments

Comments
 (0)