SovranCode
HomeCourses Git & GitHub GitHub Pull Requests
This device
Course contentsGitHub Pull Requests · 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 · PROJECTGit Project: Two Clone Sync
NEXT LESSONGitHub Code Review
5. GitHub Collaboration 70 min

GitHub Pull Requests

Open a pull request with a clear change set, description, and linked issue so review can start from evidence.

What you will leave with

You will open a GitHub pull request from a feature branch, with a description a stranger can review and a linked issue, on a repository you own. You will not confuse that page with git pull, and you will not start a review-comment thread yet.

Pull requests are GitHub, not git pull

Git Remote already used git pull: fetch, then integrate a named remote branch into your current branch. A GitHub pull request is different. It is a conversation on GitHub that proposes merging one Git branch into another—usually a feature branch into main. There is no git pr command. Opening the page does not move main until someone merges.

GIT

git pull

Updates your local branch from a remote. No GitHub page. No review thread.

GITHUB

Pull request

A numbered GitHub conversation: title, description, commits, and diff. Reviewers read it. Merge is a later GitHub action.

# These are Git. None of them opens a GitHub pull request.
git pull origin main
git fetch origin
git merge origin/main

Git Project: Two Clone Sync pushed commits to main because the job was two working copies sharing history. This lesson is the review path: the default branch stays put until the change is accepted.

Do not open practice pull requests on someone else's project

Use a disposable GitHub repository you own—the practice remote from GitHub Repository is enough. Noise PRs on a popular repository are not a lab.

Change lives on a branch

Create a short-lived branch from an up-to-date main, as Git Branch taught. One intention per branch. Push that branch. Do not commit the review work on main and then try to open a pull request from main into main—GitHub has nothing to compare.

# From a clone of a GitHub repository YOU own, with a clean main
git switch main
git pull origin main
git switch -c feature/readme-clone-section

# Edit README.md: add a Clone heading and the git clone URL, then:
git add README.md
git diff --cached
git commit -m "Document how to clone this repository"
git push -u origin feature/readme-clone-section
git branch -vv

git push -u origin feature/readme-clone-section sends the commits and sets upstream. After it succeeds, git branch -vv shows [origin/feature/readme-clone-section]. The files on GitHub’s main have not changed yet. That is the point.

QUICK CHECK

Test what you learned

Type the command that publishes the current feature branch named feature/readme-clone-section and sets upstream.

Change set, why, verify, linked issue

A useful pull request tells a stranger what to look at. The diff is the change set. The description is the argument.

What changed

Name the files and the intention. “Document how to clone” beats “updates”.

Why

The problem this solves. Link the GitHub issue that already stated expected result and reproduction.

How to verify

Numbered steps a reviewer can run without guessing. “Looks good” is not a step.

Linked issue

Closes #1 (or Fixes #1) in the body is a GitHub convention. After the pull request merges, GitHub can close that issue. Git itself does not.

## Summary
Adds a Clone section to README so a stranger can copy the GitHub Git URL.

## Linked issue
Closes #1

## How to verify
1. Open README.md on this branch.
2. Confirm the clone command uses the GitHub Git URL, not a Pages URL.
3. Confirm no other files changed.

Keep the diff small. A README heading plus one clone command is enough for this lesson. Do not mix a rename, a formatter sweep, and a behavior change in the same pull request—reviewers cannot tell which part is the claim.

Create the pull request

Stay on the feature branch. origin must already have that branch. Then create the GitHub conversation.

gh pr create --base main --title "Document how to clone this repository" --body "$(cat <<'EOF'
## Summary
Adds a Clone section to README so a stranger can copy the GitHub Git URL.

## Linked issue
Closes #1

## How to verify
1. Open README.md on this branch.
2. Confirm the clone command uses the GitHub Git URL, not a Pages URL.
EOF
)"

The website Compare & pull request button is the same object: base main, compare the feature branch, title, body. Fill the body. Do not rely on gh pr create --fill as the quality path; it copies the commit message and skips the verify steps.

QUICK CHECK

Test what you learned

Type the GitHub CLI command that opens a pull request (base, title, and body flags come after).

Open an issue first if you do not already have one from GitHub Issues. A task issue (“README has no clone command; expected a stranger can copy the Git URL”) is enough. Then put Closes #N in the pull request body with that number.

List, view, and merge on a repo you own

gh pr list
gh pr view 1
gh pr merge 1 --merge

git fetch origin
git switch main
git pull origin main
git log --oneline --decorate -n 5
git branch -vv

gh pr list shows open pull requests on the GitHub repository for this directory. gh pr view 1 prints the description so you can check whether a stranger could review it. On a disposable repository you own, you may self-merge with gh pr merge 1 --merge so GitHub records a merge commit on main. Then fetch and update local main. The merge happened on GitHub; git pull only brings that result home.

Use --merge here so the graph stays a two-parent merge, the shape Git Merge already taught. Squash and rebase merge buttons are GitHub options for a later lesson. Do not force-push the feature branch to rewrite the pull request after you have asked someone to look at it.

QUICK CHECK

Test what you learned

Type the GitHub CLI command that lists pull requests for this repository.

Review comments are the next lesson

This workshop opens a reviewable pull request. Line comments, requested changes, and merge strategy choices are GitHub Code Review. Do not spam a teammate for a rubber-stamp on a practice README.

Same-repo vs fork pull requests

Same repository

You push a feature branch to origin on a repo you can write to, then open a pull request into that repo’s main. Practice this lesson this way.

From a fork

A GitHub Fork is a different GitHub repository. You push the branch to your origin, then open a pull request that targets the original’s main. Do not git push upstream main.

This lab

Stay on a repository you own. A fork PR against a popular upstream is not the first pull request to open.

Base and compare

Base is the branch that should receive the change, usually main. Compare is the feature branch. If they point at the same commit, GitHub has no diff.

What not to open

A PR from main into main

There is no change set. Branch first, then open.

A PR with no description

The diff is not a substitute for why and how to verify.

Secrets in the diff

Tokens and private keys in a pull request are as public as a commit. Keep them out the way Git .gitignore taught.

Someone else's default branch

Do not open a practice pull request on a project you do not maintain. Do not merge other people's pull requests as a lab.

Guided practice: one reviewable PR

  1. 01
    Pick a repository you own

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

  2. 02
    Open or reuse an issue

    If README has no clone section, that is the problem. Create the issue, or reuse one from GitHub Issues. Record the number.

  3. 03
    Branch, commit, push

    git switch -c feature/readme-clone-section. One commit. git push -u origin feature/readme-clone-section.

  4. 04
    Create the pull request

    gh pr create --base main with a summary, verify steps, and Closes #N. Then gh pr view.

  5. 05
    Merge on GitHub, then pull

    gh pr merge --merge on this disposable repo. Fetch and update local main. Confirm the README change is on main and the issue is closed.

Independent lab: pull request

  1. On a GitHub repository you own, open or reuse an issue that names a small, real gap (a missing README section is enough).
  2. Create a feature branch, make one focused commit, and git push -u origin that branch. Do not commit the change on main.
  3. Open a pull request with gh pr create. The body must include what changed, how to verify, and Closes #N.
  4. Show gh pr list including that pull request, and gh pr view of its number.
  5. Write five lines: repository URL, branch name, pull request number, issue number, and one sentence that distinguishes git pull from a GitHub pull request. Merge only on this disposable repo. Do not open the pull request on a project you do not maintain.
Definition of done

You can explain that a pull request is GitHub, push a feature branch instead of reviewing on main, open a description a stranger can verify, link an issue with Closes #N, and list the pull request with gh pr list.

Common pull request mistakes

Calling git pull a pull request

git pull is Git. The review page is GitHub. The names rhyme; the jobs do not.

Working on main

If both sides of the compare are main, there is nothing to review. Use a feature branch.

Empty or lazy description

Commit messages alone skip verify steps. Write the body on purpose.

Practicing on a stranger’s repo

That is noise. Use a repository you created. Fork PRs against upstream wait until this same-repo shape is clean.

Lesson review

You can open a GitHub pull request that a stranger can review, keep git pull distinct from that page, and practice without spamming another project. Line-by-line review comments stay for the next collaboration lesson.

  • I know a GitHub pull request is a review conversation, not git pull and not a Git object.
  • I can push a feature branch with git push -u origin and leave main unchanged until merge.
  • I can gh pr create, gh pr list, and gh pr view with a description that includes verify steps and Closes #N.
  • I practice on a repository I own, and I do not open a pull request on a project I do not maintain.

Related lessons

  • GitHub Issues — Link the change that closes the issue.
  • Git Branch — A pull request compares two Git branches.
  • GitHub Fork — Many contributions start from a fork plus a feature branch.
  • Git Remote — You push the branch with Git; GitHub stores the review conversation.
  • GitHub Code Review — The pull request is the review surface.
  • GitHub Contributing — An outsider's pull request still starts from a fork or a write-access branch.
KNOWLEDGE CHECK

Check your GitHub Pull Requests model

Separate git pull from a GitHub pull request, open a reviewable change from a feature branch, and link an issue on a repository you own.

01What is a GitHub pull request?
02Does git pull open a GitHub pull request?
03Why push a feature branch instead of committing straight to main?
04What belongs in a useful pull request description?
05Which command opens a GitHub pull request from the current branch?
06Where should you open practice pull requests for this lesson?
07What does Closes #1 in a pull request body do?
PREVIOUS · PROJECTGit Project: Two Clone Sync
NEXT LESSONGitHub Code Review
ON THIS PAGEGitHub Pull RequestsPull requests are GitHub, not git pullChange lives on a branchChange set, why, verify, linked issueCreate the pull requestList, view, and merge on a repo you ownSame-repo vs fork pull requestsWhat not to openGuided practice: one reviewable PRIndependent lab: pull requestCommon pull request mistakesLesson reviewKnowledge checkRelated lessons
Course contents