GITHUB-FOUNDATIONS practice question 8 of 15

How are commits related to pull requests?

Full set: 75 questions
Answer options
A: Commits are made on a branch that can have a linked pull request. Correct answer
B: Commits can only be made after a pull request is created.
C: Commits can only be made before a pull request is created.
D: Commits are made on a pull request that can have a linked branch.
Correct Answer:
A. Commits are made on a branch that can have a linked pull request.
Explanation

On GitHub, commits are always recorded on a branch in a repository. A pull request (PR) is merely a comparison view that proposes merging one branch into another; it references whatever commits exist on the source branch. You may create a PR at any time after the first commit on a branch, and any subsequent commits pushed to that same branch are automatically added to the open PR. Therefore the relationship is: commits belong to a branch, and a pull request can be linked to that branch to aggregate those commits.

Why Incorrect

B. Commits can precede or follow PR creation; they are not restricted to after a PR exists.
C. Additional commits can be added while a PR is open, so they are not limited to before PR creation.
D. Commits are created on branches; a PR is not an entity that directly hosts commits.

References

1. GitHub Docs – “About pull requests”, §“Commits in a pull request” (docs.github.com/en/pull-requests/collaborating-with-issues-and-pull-requests/about-pull-requests)

2. GitHub Docs – “About branches”, ¶2-3 (docs.github.com/en/get-started/quickstart/github-flow#making-a-branch)

3. GitHub Docs – “GitHub Flow”, Step 4 “Open a Pull Request” (docs.github.com/en/get-started/quickstart/github-flow#open-a-pull-request)

Scroll to Top