GH-900 practice question 4 of 15

How are commits related to pull requests?

Full set: 144 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

A pull request is a mechanism for proposing and collaborating on changes to a repository. The standard workflow involves creating a new branch, making one or more commits on that branch to implement a feature or fix, and then opening a pull request. The pull request is intrinsically linked to this source branch, serving as a forum to review and discuss the commits contained within it before they are merged into a target branch (e.g., main). New commits can be added to the branch even after the pull request is open, and they will automatically be included for review.

Why Incorrect

B. Commits can only be made after a pull request is created. This is incorrect. A pull request cannot be created without at least one commit on a branch to propose for merging.
C. Commits can only be made before a pull request is created. This is incorrect. It is common practice to push new commits to a branch to address feedback after a pull request has been opened.
D. Commits are made on a pull request that can have a linked branch. This inverts the relationship. Commits are fundamental Git objects made on a branch; a pull request is a platform-specific feature that tracks the commits on that branch.

References

1. GitHub Docs

"About pull requests." In the section "Proposing changes to your work with pull requests

" the documentation states

"Pull requests let you tell others about changes you've pushed to a branch in a repository on GitHub. Once a pull request is opened

you can discuss and review the potential changes with collaborators and add follow-up commits before your changes are merged into the base branch." This confirms that commits are made on a branch and can be added both before and after the PR is created.

2. MIT

"The Missing Semester of Your CS Education

" Lecture 6: Version Control (Git). The course materials describe the collaborative workflow where developers "make some commits" on a feature branch and then open a pull request on a platform like GitHub to have those commits reviewed and merged. This establishes the correct sequence and relationship described in option A. (See the "Collaboration" section of the lecture notes).

3. Pro Git Book (2nd Edition)

Scott Chacon and Ben Straub

Chapter 6.2 "GitHub - Contributing to a Project." This authoritative text outlines the "Fork & Pull Request" model. Section 6.2 details the process: create a topic branch

make commits

and then open a Pull Request. This workflow explicitly shows that commits are made on a branch which is then the subject of a pull request.

Scroll to Top