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
Handling PR Feedback and Updates
📖 Scenario: You are working on a team project using Git and GitHub. Your teammate has reviewed your Pull Request (PR) and left feedback asking for some changes. You need to update your PR with the requested fixes so the team can merge your work smoothly.
🎯 Goal: Learn how to fetch PR feedback, make changes in your local branch, commit those changes, and push updates to the same PR branch on GitHub.
📋 What You'll Learn
Create a new branch called feature-update from main
Make a simple change to a file called app.txt by adding the line Update after PR feedback
Commit the change with the message fix: update after PR feedback
Push the updated branch feature-update to the remote repository
💡 Why This Matters
🌍 Real World
In real projects, teammates review your code and ask for changes. You update your PR branch with fixes so the team can merge your work smoothly.
💼 Career
Knowing how to handle PR feedback and update branches is essential for collaboration in software development teams using Git and GitHub.
Progress0 / 4 steps
1
Create a new branch for your PR updates
Use the command git checkout -b feature-update to create and switch to a new branch called feature-update from main.
Git
Hint
Think of this as creating a new workspace to make your changes without disturbing the main code.
2
Make the requested change in app.txt
Add the line Update after PR feedback at the end of the file app.txt using a command like echo or by editing the file.
Git
Hint
Use echo "text" >> filename to add a line to the end of a file.
3
Commit your changes with a clear message
Use git add app.txt to stage the file, then commit with git commit -m "fix: update after PR feedback" to save your changes locally.
Git
Hint
Remember to stage your changes before committing.
4
Push your updated branch to the remote repository
Use git push origin feature-update to send your updated branch to GitHub, updating the existing PR with your fixes.
Git
Hint
This command updates your remote branch so the PR reflects your new changes.
Practice
(1/5)
1. When you receive feedback on a pull request (PR), what is the first step to update your code accordingly?
easy
A. Check out the feature branch locally to make changes
B. Merge the main branch into your feature branch without changes
C. Close the PR and create a new one
D. Delete the feature branch and start over
Solution
Step 1: Switch to the feature branch
You need to work on the branch where the PR was created to apply feedback changes.
Step 2: Make the necessary code updates
After switching, edit the code to address the feedback.
Final Answer:
Check out the feature branch locally to make changes -> Option A
Quick Check:
Update code on feature branch = A [OK]
Hint: Always update code on the feature branch first [OK]
Common Mistakes:
Trying to update main branch instead of feature branch
Closing PR unnecessarily
Starting a new branch without reason
2. Which git command correctly stages all changed files before committing updates for a PR?
easy
A. git commit -a -m "Update code"
B. git checkout -b update-branch
C. git push origin main
D. git add .
Solution
Step 1: Stage all changes
The command git add . stages all modified and new files in the current directory.
Step 2: Commit the staged changes
After staging, you use git commit -m "message" to save changes locally.
Final Answer:
git add . -> Option D
Quick Check:
Stage all changes = git add . [OK]
Hint: Use 'git add .' to stage all changes before commit [OK]
Common Mistakes:
Using git commit -a without staging new files
Pushing before committing
Creating new branches unnecessarily
3. Given the following commands run in sequence on a feature branch:
What happens to the existing pull request linked to feature-branch?
medium
A. A new pull request is created
B. The pull request updates automatically with the new commit
C. The pull request is closed
D. Nothing changes until you merge manually
Solution
Step 1: Push updates to the feature branch
Pushing commits to the branch linked to the PR updates the PR automatically.
Step 2: PR reflects new commits
The PR shows the new changes for reviewers to see and re-review.
Final Answer:
The pull request updates automatically with the new commit -> Option B
Quick Check:
Push to feature branch updates PR = A [OK]
Hint: Push changes to update existing PR automatically [OK]
Common Mistakes:
Thinking a new PR is needed for each update
Believing PR closes on push
Assuming manual merge needed to update PR
4. You tried to push updates to your feature branch but got this error: ! [rejected] feature-branch -> feature-branch (non-fast-forward) What is the best way to fix this?
medium
A. Pull latest changes from remote and rebase before pushing
B. Delete the remote branch and push again
C. Force push with git push --force
D. Create a new branch and push there
Solution
Step 1: Fetch and rebase remote changes
Run git pull --rebase origin feature-branch to update your local branch with remote changes without merge commits.
Step 2: Push the rebased branch
After rebasing, push your changes normally with git push origin feature-branch.
Final Answer:
Pull latest changes from remote and rebase before pushing -> Option A
Quick Check:
Fix non-fast-forward by rebasing and pushing = C [OK]
Hint: Rebase remote changes before pushing to avoid errors [OK]
Common Mistakes:
Using force push without caution
Deleting remote branch unnecessarily
Creating new branches instead of syncing
5. You have multiple commits in your feature branch but want to combine them into one clean commit before updating the PR. Which sequence of commands achieves this?