SovranCode
HomeCourses Git & GitHub GitHub Contributing
This device
Course contentsGitHub Contributing · 41 topics

1. Git Fundamentals

Git IntroductionGit Version ControlGit vs GitHubGit InstallationGit Working TreeGit RepositoryGit CommitGit .gitignoreGit Project: Learning Journal

2. Git History

Git LogGit DiffGit ResetGit RevertGit StashGit Project: Messy Repository

3. Branches & History

Git BranchGit MergeGit Merge ConflictsGit RebaseGit Cherry-PickGit TagsGit Project: Feature Branch

4. Remotes and GitHub

Git RemoteGitHub AuthenticationGitHub RepositoryGitHub ForkGitHub IssuesGitHub PagesGit Project: Two Clone Sync

5. GitHub Collaboration

GitHub Pull RequestsGitHub Code ReviewGit Branching WorkflowGitHub Branch ProtectionGitHub CollaborationGitHub ContributingGit Project: Reviewed Pull Request

6. Automation and Professional Git

GitHub ActionsGit InternalsGit RecoveryGitHub SecurityGit Project: Team Repository CIProject
Learn Git & GitHub40 complete · 1 planned

1. Git Fundamentals

Git IntroductionGit Version ControlGit vs GitHubGit InstallationGit Working TreeGit RepositoryGit CommitGit .gitignoreGit Project: Learning Journal

2. Git History

Git LogGit DiffGit ResetGit RevertGit StashGit Project: Messy Repository

3. Branches & History

Git BranchGit MergeGit Merge ConflictsGit RebaseGit Cherry-PickGit TagsGit Project: Feature Branch

4. Remotes and GitHub

Git RemoteGitHub AuthenticationGitHub RepositoryGitHub ForkGitHub IssuesGitHub PagesGit Project: Two Clone Sync

5. GitHub Collaboration

GitHub Pull RequestsGitHub Code ReviewGit Branching WorkflowGitHub Branch ProtectionGitHub CollaborationGitHub ContributingGit Project: Reviewed Pull Request

6. Automation and Professional Git

GitHub ActionsGit InternalsGit RecoveryGitHub SecurityGit Project: Team Repository CIProject
PREVIOUS LESSONGitHub Collaboration
NEXT · UNIT PROJECTGit Project: Reviewed Pull Request
5. GitHub Collaboration 70 min

GitHub Contributing

Read a contributing guide, fork or branch correctly, keep a small diff, and respond to review without rewriting shared history.

What you will leave with

You will add a CONTRIBUTING.md on a repository you own, choose fork versus write-access branch, send one small issue-linked pull request, and answer review with git push—not a force-push and not git push upstream main. You will not rewrite the Fork, Pull Requests, or Code Review lessons, and you will not open a practice pull request on a famous project.

The guide is Git; the path is GitHub

GitHub Collaboration gave issues and pull requests a repeatable shape. This lesson is the outsider path: read the project's contributing guide, then send a change the maintainers can review. GitHub Fork already named origin and upstream. GitHub Pull Requests already opened a same-repo pull request. Here you choose the correct path and keep the diff small.

GIT

The files and the branch

CONTRIBUTING.md is an ordinary path. git add stages it. The feature branch is a Git pointer. Follow-up commits are Git objects.

GITHUB

Fork, pull request, and review

Fork copies the hosted repository into your namespace. The pull request compares your head with their default branch. Review comments stay on GitHub.

# These are Git. None of them is a GitHub contribution.
git add README.md
git commit -m "Note"
git push origin main

Use a disposable GitHub repository you own for the files and the write-access walkthrough. Write the fork commands; do not fire them at a popular project's Issues tab as homework.

A guide does not grant write access

Publishing CONTRIBUTING.md does not let strangers push main. That is still GitHub Branch Protection plus GitHub permissions. Outsiders fork or wait to be added as collaborators.

Read before you write

Before you touch files on a project you do not maintain, read what that project already published. GitHub shows a contributing banner when CONTRIBUTING.md or .github/CONTRIBUTING.md exists. That banner is GitHub. The file is Git.

# Contributing

This repository accepts small, issue-linked changes.

## Before you write code
1. Read this file and the issue / pull request templates.
2. Search existing issues. Open one if the problem is not listed.
3. Wait for a maintainer to confirm the work is wanted, unless the issue already invites a pull request.

## How to send a change
- If you have write access: branch from the default branch. Do not commit on `main`.
- If you do not: fork on GitHub, clone your fork, add `upstream`, fetch, then branch from `upstream/main`.
- Keep one concern per pull request. Do not mix docs, refactors, and features.
- Open a pull request against the original default branch. Fill the pull request template. Link `Closes #N`.
- After review: commit the fix on the same branch and `git push`. Do not force-push once review has started.

## What we will not merge
- Drive-by reformatting of files you did not otherwise change
- Secrets, tokens, or generated files
- Changes that skip the issue when this file asked for one
# From a clone of a GitHub repository YOU own
git switch main
git pull origin main
git switch -c feature/contrib-guide

# Write CONTRIBUTING.md at the repository root, then:
git add CONTRIBUTING.md
git diff --cached
git commit -m "Add a contributing guide for small issue-linked changes"
git push -u origin feature/contrib-guide
QUICK CHECK

Test what you learned

Type the Git command that stages CONTRIBUTING.md at the repository root.

CONTRIBUTING.md

How to send a change: issue first or not, fork or branch, small diffs, how to answer review.

Templates

Issue and pull request templates from Collaboration still apply. Fill them. Do not paste a screenshot of git status instead of a reproduction.

Code of conduct

If CODE_OF_CONDUCT.md exists, it is a Git file about behavior, not a Git command. Read it. Do not debate it in the pull request.

DCO or CLA

If the guide asks for a Developer Certificate of Origin, git commit -s adds a Git sign-off trailer. A GitHub CLA bot is GitHub. Follow the file; do not invent a signing lesson here.

Search existing issues. Open a complete issue when the guide requires one. GitHub Issues already required problem, expected result, and reproduction. A surprise pull request that skips that contract is why maintainers close drive-by work.

Fork or write-access branch

The contributing guide, not habit, chooses the path. Git does not know whether you are a collaborator. GitHub permissions do.

Write access

Clone the original as origin. git switch -c feature/contrib-note. Push that branch. Open a pull request in the same repository. Do not commit on main.

No write access

Fork on GitHub. Clone your fork. origin is you; upstream is them. Fetch, catch up, then branch from current upstream/main.

Never the default branch

git push upstream main aims at someone else's shared history. Permission denied is the correct answer. Do not force-push to “fix” it.

This lab

Add the guide and walk the write-access path on a repository you own. Keep the fork-path commands written down so you can run them when you lack write access for real.

# You already have write access. CONTRIBUTING.md said: branch, do not commit on main.
git switch main
git pull origin main
git switch -c feature/contrib-note

# Make ONE small change the issue asked for, then:
git add README.md
git diff --cached
git commit -m "Note how outsiders should read CONTRIBUTING.md"
git push -u origin feature/contrib-note
gh pr create --base main --title "Note the contributing guide in README" --body "$(cat <<'EOF'
## Summary
Points README at CONTRIBUTING.md so a stranger knows how to send a change.

## Linked issue
Closes #1

## How to verify
1. Open README.md on this branch.
2. Confirm it links CONTRIBUTING.md.
3. Confirm no other files changed.
EOF
)"
QUICK CHECK

Test what you learned

Type the Git command that creates and switches to feature/contrib-note.

GitHub cannot fork a repository into the same account that already owns it. That is why this workshop does not pretend you forked your own practice repo. The fork commands below are the real outsider path; they use ORIGINAL/REPO and YOU as placeholders, the same way GitHub Fork did.

Keep a small diff

A contribution is one concern. Maintainers review the patch, not your formatter. Before you open the pull request, inspect the range the review will see.

One issue

The branch exists because of one GitHub issue. Closes #N names it. A second concern is a second branch.

Inspect the range

git diff main...HEAD --stat should list only the files that issue required. Extra files are extra review.

Not a rewrite

Do not re-indent a file you did not change. Do not upgrade every dependency as a “drive-by.”

Not a dump

Do not include editor swap files, node_modules, or tokens. Git .gitignore still applies.

Open the pull request against the original

Same-repo pull requests used gh pr create --base main in GitHub Pull Requests. A fork-based contribution must name the original repository, or GitHub will open the conversation on your fork—where the maintainers are not watching.

# You do NOT have write access. Fork first (GitHub), then clone YOUR copy.
# origin = your fork. upstream = ORIGINAL/REPO. See GitHub Fork.

git switch main
git fetch upstream
git merge upstream/main
git push origin main
git switch -c feature/contrib-note

# Small change, commit, then:
git push -u origin feature/contrib-note
gh pr create --repo ORIGINAL/REPO --base main --head YOU:feature/contrib-note --title "Note the contributing guide in README" --body "$(cat <<'EOF'
## Summary
Points README at CONTRIBUTING.md so a stranger knows how to send a change.

## Linked issue
Closes #1

## How to verify
1. Open README.md on this branch.
2. Confirm it links CONTRIBUTING.md.
3. Confirm no other files changed.
EOF
)"
QUICK CHECK

Test what you learned

Type the GitHub CLI command that opens a pull request on ORIGINAL/REPO (the flags come after).

--head YOU:feature/contrib-note is GitHub's name for “the branch on this user's fork.” Git still pushed that branch to origin. GitHub stores the comparison. After it merges, fetch and update your fork's default branch the way the Fork lesson taught—do not push the original main.

Respond without rewriting shared history

GitHub Code Review already required this habit. It is the same habit when you are the outsider: requested changes are answered on the same feature branch with an ordinary push.

# Stay on feature/contrib-note. Review already started.
# Edit the same files the review named, then:
git add README.md
git diff --cached
git commit -m "Use the path the review asked for"
git push

# These rewrite history reviewers already read. Do not run them on a shared pull request:
# git push --force
# git push --force-with-lease

Same branch

Do not open a second pull request for the fix. The conversation already points at this head.

Ordinary push

git push adds a commit reviewers can diff against the comment they left.

No force-push

Once review has started, rewriting that branch hides the commits people already read. Save --force-with-lease for private cleanup before the first review, if the guide allows it.

Then stop

Do not merge the original default branch unless you are a maintainer. After merge, sync your fork. Delete the feature branch.

What not to invent

Practice PRs on famous repos

Do not open a “typo” pull request on a popular project as this course's homework. Maintainers are not a lab.

CONTRIBUTING.md on a stranger's default branch

Your practice guide belongs on a repository you own. Adding process files to someone else's project is not a first contribution unless they asked.

Actions as a contribution

A workflow file is GitHub Actions. Do not drop .github/workflows into a project whose guide never asked for it.

Tokens in the diff

Do not paste a personal access token into a pull request to “prove auth.” Authentication already taught secret hygiene.

Guided practice: guide, then one change

  1. 01
    Pick a repository you own

    Confirm git remote -v is your GitHub URL. Update local main.

  2. 02
    Add the guide

    On feature/contrib-guide, add CONTRIBUTING.md with the two paths (write access versus fork), a small-diff rule, and “no force-push after review.” Open a pull request and merge it.

  3. 03
    Open one issue

    File a complete issue: problem, expected result, reproduction. The work is a one-line README pointer to CONTRIBUTING.md.

  4. 04
    Send the write-access change

    git switch -c feature/contrib-note. Make that one README change. Push. Open a pull request with Closes #N.

  5. 05
    Request a change, then answer it

    Leave a review that asks for a clearer sentence. Fix it on the same branch. git push without force. Then merge if you are done.

  6. 06
    Write the fork path

    On paper or in the lab notes, record gh pr create --repo ORIGINAL/REPO with --head YOU:feature/contrib-note. Do not run it against a project you do not maintain.

Independent lab: contributing path

  1. On a GitHub repository you own, add CONTRIBUTING.md that names both paths (write-access branch versus fork), requires a small issue-linked diff, and forbids force-push once review has started. Land it through a short-lived pull request.
  2. Open one complete GitHub issue. On feature/contrib-note, make a single matching change. Open a pull request that fills the template and includes Closes #N.
  3. Request one change on that pull request. Answer with a new commit and git push. Do not use git push --force.
  4. Write the fork-based command you would run without write access, including gh pr create --repo ORIGINAL/REPO. Do not open that pull request on a popular public project.
  5. Write six lines: repository URL, issue number, pull request number, whether this walkthrough used write access or a fork, one sentence that distinguishes CONTRIBUTING.md from a GitHub label, and one sentence that distinguishes git push after review from git push --force.
Definition of done

You can publish a contributing guide, choose fork versus write-access branch, send a small issue-linked pull request, and answer review with an ordinary push—on a repository you own, without using maintainers of other projects as the lab.

Common contributing mistakes

Skipping the guide

If the file asked for an issue first, a surprise pull request is incomplete work, not speed.

Calling clone a contribution

Clone is Git. Fork is GitHub. A pull request against the original is the contribution.

A giant unrelated diff

Format-the-world patches get closed. One concern per branch.

Force-pushing the review away

New commits keep the thread honest. Rewrite after review has started hides what people already read.

Lesson review

You can read a contributing guide, pick fork or write-access branch, keep the change small, open the pull request against the original repository, and answer review without rewriting shared history. The unit project that walks a full reviewed pull request is Git Project: Reviewed Pull Request. A check reviewers can trust is GitHub Actions.

  • I know CONTRIBUTING.md is a Git file GitHub surfaces, not a git contribute command.
  • I can choose fork (no write access) versus a feature branch on the original (write access).
  • I can open gh pr create --repo ORIGINAL/REPO from a fork head, or a same-repo pull request when I already have write access.
  • I answer requested changes with git push on the same branch, not with force-push or git push upstream main.

Related lessons

  • GitHub Fork — Most external contributions start from a fork.
  • GitHub Pull Requests — The change returns as a reviewed pull request.
  • GitHub Code Review — Answer requested changes with a follow-up push, not a rewrite of shared history.
  • GitHub Collaboration — Read the issue and pull request templates before you file.
  • GitHub Issues — Start from a complete issue when the guide asks for one.
KNOWLEDGE CHECK

Check your GitHub Contributing model

Read the guide, choose fork or write-access branch, keep the diff small, and answer review without rewriting shared history.

01What is CONTRIBUTING.md?
02When should you fork instead of branching on the original clone?
03What belongs in a useful first contribution?
04What should you read before you write code on someone else's project?
05How do you answer requested changes once review has started?
06Where should a fork-based pull request be created?
07Where should you practice this lesson?
PREVIOUS LESSONGitHub Collaboration
NEXT · UNIT PROJECTGit Project: Reviewed Pull Request
ON THIS PAGEGitHub ContributingThe guide is Git; the path is GitHubRead before you writeFork or write-access branchKeep a small diffOpen the pull request against the originalRespond without rewriting shared historyWhat not to inventGuided practice: guide, then one changeIndependent lab: contributing pathCommon contributing mistakesLesson reviewKnowledge checkRelated lessons
Course contents