Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Pull Request Process
📖 Scenario: You are working on a team project using Git. Your team uses pull requests to review and merge code changes safely. You will practice the basic pull request process using Git commands.
🎯 Goal: Learn how to create a new branch, make a commit, push the branch to a remote repository, and open a pull request for code review.
📋 What You'll Learn
Create a new branch called feature-update
Make a commit with the message Update README with project info
Push the feature-update branch to the remote repository
Open a pull request from feature-update to main
💡 Why This Matters
🌍 Real World
Teams use pull requests to review code changes before merging to main projects. This helps catch mistakes and improve code quality.
💼 Career
Knowing how to create and manage pull requests is essential for collaboration in software development jobs.
Progress0 / 4 steps
1
Create a new branch
Use the command git checkout -b feature-update to create and switch to a new branch called feature-update.
Git
Hint
This command creates a new branch and switches to it in one step.
2
Make a commit with a message
Use git commit -m "Update README with project info" to commit your changes with the exact message Update README with project info.
Git
Hint
Make sure to include the message exactly as shown inside double quotes.
3
Push the branch to remote
Use git push origin feature-update to push the feature-update branch to the remote repository named origin.
Git
Hint
This command uploads your branch to the remote repository so others can see it.
4
Open a pull request
Use the command gh pr create --base main --head feature-update --title "Update README with project info" --body "This pull request updates the README file with project information." to open a pull request from feature-update to main with the given title and description.
Git
Hint
This command uses GitHub CLI to open a pull request with a clear title and description.
Practice
(1/5)
1. What is the main purpose of a pull request in Git?
easy
A. To ask your team to review and merge your code changes
B. To delete a branch from the repository
C. To create a new branch locally
D. To clone a repository to your computer
Solution
Step 1: Understand the role of a pull request
A pull request is a request to merge code changes and get feedback from the team.
Step 2: Identify the correct purpose
Options B, C, and D describe other Git actions unrelated to pull requests.
Final Answer:
To ask your team to review and merge your code changes -> Option A
Quick Check:
Pull request = code review request [OK]
Hint: Pull request means asking for code review and merge [OK]
Common Mistakes:
Confusing pull request with branch creation
Thinking pull request deletes branches
Mixing pull request with cloning repositories
2. Which Git command is used to upload your local branch to the remote repository before creating a pull request?
easy
A. git clone origin branch-name
B. git pull origin branch-name
C. git push origin branch-name
D. git fetch origin branch-name
Solution
Step 1: Identify the command to upload local changes
The git push command sends local commits to the remote repository.
Step 2: Match the correct syntax
git push origin branch-name uploads the specified branch to the remote named origin.
Final Answer:
git push origin branch-name -> Option C
Quick Check:
Push = upload branch to remote [OK]
Hint: Push uploads your branch to remote before pull request [OK]
Common Mistakes:
Using git clone instead of git push
Confusing git pull with git push
Using git fetch which only downloads data
3. After pushing your branch and creating a pull request, what is the expected output when you run git status on your local branch?
medium
A. On branch feature-xyz
nothing to commit, working tree clean
B. On branch feature-xyz
your branch is ahead of 'origin/feature-xyz' by 1 commit
C. On branch main
nothing to commit, working tree clean
D. On branch feature-xyz
You have unmerged paths.
Solution
Step 1: Understand the state after pushing and creating pull request
After pushing, local and remote branches are synced, so no new commits locally.
Step 2: Interpret git status output
"nothing to commit, working tree clean" means no changes locally; branch is up to date.
Final Answer:
On branch feature-xyz
nothing to commit, working tree clean -> Option A
Quick Check:
Clean status means local branch matches remote [OK]
Hint: Clean git status means branch is synced after push [OK]
Common Mistakes:
Thinking branch is ahead after push
Confusing branch names
Expecting unmerged paths without conflicts
4. You created a pull request but forgot to push your latest commit. What error will you most likely see when trying to create the pull request?
medium
A. Pull request created successfully with all commits
B. Error: No commits found on branch to compare
C. Merge conflict detected automatically
D. Remote branch does not exist
Solution
Step 1: Understand the pull request creation process
A pull request compares your remote branch with the base branch.
Step 2: Identify the error when branch is not pushed
If you forget to push, the remote branch does not exist, causing an error.
Final Answer:
Remote branch does not exist -> Option D
Quick Check:
Pull request needs remote branch [OK]
Hint: Push branch first or remote branch won't exist [OK]
Common Mistakes:
Assuming pull request works without pushing
Expecting merge conflict before push
Ignoring remote branch creation step
5. You want to ensure your pull request is merged only after at least two team members approve it. Which GitHub feature should you configure?
hard
A. Enable auto-merge without reviews
B. Branch protection rules with required reviews set to 2
C. Use git rebase to combine commits
D. Create a new branch for each reviewer
Solution
Step 1: Identify how to enforce review requirements
GitHub branch protection rules allow setting required number of reviewers before merge.
Step 2: Match the feature to the requirement
Setting required reviews to 2 ensures at least two approvals before merging.
Final Answer:
Branch protection rules with required reviews set to 2 -> Option B
Quick Check:
Branch protection = enforce review count [OK]
Hint: Use branch protection rules to require reviews [OK]