What is a PR?
- Git course
- Intermediate
- Lesson 49/82
- 4 min
Learn that a pull request is a code review flow.
What is a pull request?
A pull request (PR) is a GitHub feature that proposes bringing changes from one branch into another, usually the main branch. When a PR is opened, team members can review the code, discuss changes, and decide whether to merge them. This process is called a code review.
feature-login ---- PR ----> mainA pull request is not a local Git command; it is a collaboration feature provided by platforms such as GitHub.
Source and target branches
When creating a PR, the source branch contains the changes. The target branch is where those changes are proposed to be added. For example, feature-login can be the source branch and main the target branch.
Base: main
Compare: feature-loginGitHub displays the commit and file differences between these branches to make review easier. Similar workflows are called merge requests on platforms such as GitLab.
Practice Define the PR direction
Write two lines defining feature-login as the source branch and main as the target branch for a pull request. Show the source branch in Compare and the target branch in Base.
Starter code
# Hedef dal
# Kaynak dalSample solution
# Hedef dal
Base: main
# Kaynak dal
Compare: feature-loginExpected output
Base: main Compare: feature-login
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 What is the main purpose of a pull request?
- To download a remote repository to a computer
- To submit code changes for review and merging Correct answer
- To delete all commits in the local repository
- To change Git user information
Explanation: A pull request allows changes from one branch to be reviewed and evaluated before they are brought into the target branch.
2 Set the PR target branch
Base: ____
Base: main
Explanation: The Base field identifies the target branch into which changes will be merged.
3 Pull request concepts
| Term | Meaning |
|---|---|
Pull request |
Proposal to merge changes |
Code review |
Team review of code |
Source branch |
Branch containing the changes |
Target branch |
Branch receiving the changes |