GH-900 practice question 4 of 15
How are commits related to pull requests?
Full set: 144 questionsA 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.
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.
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.
Keep practicing
Take the free GH-900 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other GH-900 practice questions
- Question 1What is the difference between an organization member and an outside collaborator?
- Question 2New open source contributors can receive funding from GitHub sponsors:
- Question 3An employee needs to find all issues within organization “Avocado" containing text "404 e…
- Question 5Where should a repository admin navigate to view pre-built visualizations from repository…
- Question 6Who can be assigned to an Issue or pull request? (Each answer presents a complete solutio…
- Question 7Which of the following is an Innersource development practice?
