Handling Pull Requests from Forks (Maintainer Guide)
# Handling Pull Requests from Forks (Maintainer Guide)
This guide explains how to safely work with PRs created from contributor forks.
---
## 0. On GitHub: Inspect the PR
On the PR page, note:
- **PR number** – e.g. `#104`
- **Source branch** – e.g. `c0nD:feature/anonymize-users`
- Confirm **“Allow edits by maintainers”** is checked if you want to push fixes into their branch.
---
## 1. Check out the PR locally
From your local `copycord` repo:
```bash
gh pr checkout <PR_NUMBER>
# example:
gh pr checkout 104
```
This will:
- Fetch the PR branch from the contributor’s fork.
- Create a local branch for the PR.
- Check out that branch so you can run tests and edit.
> **Important:** After this, avoid clicking **“Publish Branch”** in VS Code for this PR branch. Use explicit `git push` instead (see Path B / C).
---
## 2. Choose how you want to handle the PR
You have three main paths:
---
### Path A – Review only (no commits pushed)
Use this when you only want to review the PR and leave feedback.
1. Run tests and manually inspect the code on the local PR branch.
2. Leave comments, approvals, or change requests directly on GitHub.
3. No additional git configuration or pushes are needed.
---
### Path B – Push fixes *into the existing PR*
Use this when you want your commits to appear in the **same PR** from the contributor’s fork.
#### 2B-1. Add the contributor’s fork as a remote (one-time per contributor)
From your `copycord` repo:
```bash
git remote add <username> https://github.com/<username>/Copycord.git
# example:
git remote add c0nD https://github.com/c0nD/Copycord.git
```
You only need to do this **once per contributor**.
#### 2B-2. Commit your changes on the PR branch
Make sure you’re still on the PR branch (checked out via `gh pr checkout`):
```bash
git status
# On branch <pr-branch-name>
```
Stage and commit your changes:
```bash
git add .
git commit -m "Describe your changes"
```
#### 2B-3. Push into their PR branch
Use an explicit push to their fork branch (from the PR header `user:branch`):
```bash
git push <username> HEAD:<branch-name>
# example:
git push c0nD HEAD:feature/anonymize-users
```
If **“Allow edits by maintainers”** is enabled, this will:
- Push your commits into the contributor’s branch.
- Automatically update the existing PR.
> **Rule of thumb:** For contributor PR branches, **do not use VS Code’s “Publish Branch”**. Always use an explicit:
> ```bash
> git push <their-remote> HEAD:<their-branch>
> ```
---
### Path C – Create a maintainer-owned follow-up PR
Sometimes you don’t want to push to the contributor’s fork, or you want a maintainer-owned branch/PR instead.
With the PR branch checked out:
1. Optionally rename the local branch to something clearly yours:
```bash
git branch -m <your-branch-name>
# example:
git branch -m feature/anonymize-users-mac
```
2. Push it to the main repo (`origin`):
```bash
git push -u origin <your-branch-name>
# example:
git push -u origin feature/anonymize-users-mac
```
3. On GitHub, open a new PR from:
- **Base:** `Copycord:main` (or the appropriate base branch)
- **Head:** `Copycord:<your-branch-name>`
4. In the original contributor PR, comment and, if appropriate, close it. For example:
> I pulled this down, added some additional changes, and opened a follow-up PR: #<new-pr-number>. Closing this in favor of the new PR.
This is also a good path if you accidentally clicked **Publish Branch** on the PR branch and now have a branch on `origin`—just turn that into your official maintainer PR.
---
## Quick Checklist (TL;DR)
For each new PR from a fork:
1. **Inspect PR on GitHub**
- Note `user:branch` and PR number.
- Ensure **“Allow edits by maintainers”** is checked if you plan to push fixes.
2. **Check out the PR locally**
```bash
gh pr checkout <number>
```
3. **Decide your path**
- **Review only:** Just test locally and leave comments on GitHub.
- **Edit their PR:**
```bash
git remote add <user> https://github.com/<user>/Copycord.git # once per user
git commit -m "Your changes"
git push <user> HEAD:<branch-name-from-PR>
```
- **Maintainer follow-up PR:**
```bash
git branch -m <your-branch-name>
git push -u origin <your-branch-name>
```
Then open a new PR from your branch and link it from the original.
Following this guide keeps PR handling consistent, avoids confusion with VS Code’s “Publish Branch”, and makes it clear when changes land in the contributor’s fork vs. the main repo.