0
0
Gitdevops~15 mins

Handling PR feedback and updates in Git - Deep Dive

Choose your learning style9 modes available
Overview - Handling PR feedback and updates
What is it?
Handling PR feedback and updates means managing the comments and change requests you get after submitting your code for review in a Pull Request (PR). It involves reading feedback, making changes to your code, and updating the PR so others can see your improvements. This process helps teams collaborate smoothly and keep code quality high.
Why it matters
Without handling PR feedback properly, code reviews become confusing and slow. Changes might get lost, or reviewers might not see your updates, causing delays and frustration. Good feedback handling keeps the project moving forward, improves code quality, and builds trust among team members.
Where it fits
Before this, you should know how to create and submit a Pull Request using git and a platform like GitHub or GitLab. After mastering feedback handling, you can learn advanced git workflows like rebasing, squashing commits, and automating PR checks.
Mental Model
Core Idea
Handling PR feedback is a cycle of receiving comments, updating your code, and sharing those updates clearly so the team can approve your changes.
Think of it like...
It's like submitting a homework assignment to a teacher, getting notes on what to fix, making those fixes, and then handing in the improved version for final approval.
┌───────────────┐
│ Submit PR    │
└──────┬────────┘
       │
       ▼
┌───────────────┐
│ Receive       │
│ Feedback      │
└──────┬────────┘
       │
       ▼
┌───────────────┐
│ Make Changes  │
│ Locally       │
└──────┬────────┘
       │
       ▼
┌───────────────┐
│ Update PR     │
│ (push commits)│
└──────┬────────┘
       │
       ▼
┌───────────────┐
│ Reviewers See │
│ Updates       │
└───────────────┘
Build-Up - 7 Steps
1
FoundationWhat is a Pull Request
🤔
Concept: Understanding what a Pull Request (PR) is and its role in collaboration.
A Pull Request is a way to ask your team to review and merge your code changes into the main project. It shows your code, lets others comment, and helps keep the project organized.
Result
You know that a PR is the starting point for feedback and collaboration on code changes.
Understanding the PR concept is essential because feedback and updates revolve around this shared workspace for code review.
2
FoundationHow to Submit a PR
🤔
Concept: Learning the basic git commands and platform steps to create a PR.
You create a branch, make changes, commit them, push the branch to the remote, and then open a PR on platforms like GitHub. Example commands: $ git checkout -b feature-branch $ git add . $ git commit -m "Add feature" $ git push origin feature-branch Then open a PR on GitHub comparing your branch to main.
Result
You can submit your code for review and start the feedback process.
Knowing how to submit a PR sets the stage for receiving and handling feedback effectively.
3
IntermediateReading and Understanding Feedback
🤔Before reading on: do you think all feedback comments require code changes? Commit to your answer.
Concept: Learning to interpret reviewer comments and decide what needs action.
Feedback can be suggestions, questions, or requests for changes. Not all comments require code edits; some may be clarifications or approvals. Read carefully and ask questions if unclear.
Result
You can distinguish between actionable feedback and general comments.
Understanding feedback types helps you respond appropriately and avoid unnecessary changes.
4
IntermediateMaking Code Changes Locally
🤔Before reading on: do you think you should edit code directly on the PR page or locally on your machine? Commit to your answer.
Concept: Knowing how to update your code on your computer before pushing changes.
You make changes in your local branch using your editor or IDE. After editing, you stage and commit the changes with git commands: $ git add changed_file $ git commit -m "Address feedback" This keeps your history clear and organized.
Result
You have updated code ready to be shared with reviewers.
Making changes locally ensures you can test and review your fixes before sharing.
5
IntermediateUpdating the PR with New Commits
🤔Before reading on: do you think pushing new commits to your branch updates the existing PR automatically? Commit to your answer.
Concept: How pushing commits to the same branch updates the open PR.
When you push new commits to the branch linked to your PR, the PR updates automatically. Use: $ git push origin feature-branch Reviewers will see your new changes in the PR interface.
Result
Your PR reflects the latest code changes and feedback responses.
Knowing that PRs update automatically with pushes avoids confusion and duplicate PRs.
6
AdvancedUsing Interactive Rebase to Clean History
🤔Before reading on: do you think rewriting commit history after feedback is a good practice? Commit to your answer.
Concept: Learning to tidy commits before final merge using git rebase -i.
Interactive rebase lets you combine, edit, or reorder commits to make your history clean and meaningful: $ git rebase -i HEAD~3 You can squash minor fix commits into main ones, making the PR easier to review and the project history cleaner.
Result
Your commit history is clear, making it easier for others to understand your changes.
Cleaning commit history improves project maintainability and reviewer experience.
7
ExpertHandling Conflicts and Force Pushes
🤔Before reading on: do you think force pushing is safe anytime you update your PR? Commit to your answer.
Concept: Managing merge conflicts and safely updating PRs with force push when rewriting history.
If your branch conflicts with the main branch, you must resolve conflicts locally. After rebasing or amending commits, you need to force push: $ git push --force-with-lease origin feature-branch Force pushing overwrites the remote branch but can disrupt others if not done carefully. Use --force-with-lease to avoid overwriting others' work.
Result
Your PR branch is updated with resolved conflicts and clean history without breaking collaboration.
Knowing when and how to force push prevents lost work and keeps the team in sync.
Under the Hood
A Pull Request is a reference to a branch in a git repository. When you push commits to that branch, the PR updates automatically because it tracks the branch pointer. Feedback comments are stored on the hosting platform and linked to specific commits or lines. When you rebase or amend commits, the commit hashes change, so force pushing updates the remote branch to match your local history.
Why designed this way?
Git was designed as a distributed version control system with immutable commits identified by hashes. PRs leverage this by tracking branches, not individual commits, allowing continuous updates. Force pushing exists because rewriting history locally is common for clean commits, but it requires care to avoid overwriting others' work. Platforms like GitHub added PRs to simplify collaboration and code review workflows.
Local Repo                 Remote Repo (GitHub)
┌─────────────┐            ┌─────────────┐
│ feature-branch ├─push───▶│ feature-branch │
│ commits      │            │ commits      │
└─────┬───────┘            └─────┬───────┘
      │                           │
      │ edit & commit             │ PR tracks branch
      ▼                           ▼
┌─────────────┐            ┌─────────────┐
│ git rebase  │            │ PR interface│
│ force push  │◀───────────┤ updates     │
└─────────────┘            └─────────────┘
Myth Busters - 4 Common Misconceptions
Quick: Does pushing new commits to your branch create a new PR automatically? Commit yes or no.
Common Belief:Pushing new commits creates a new Pull Request every time.
Tap to reveal reality
Reality:Pushing commits to the same branch updates the existing PR automatically; no new PR is created.
Why it matters:Believing this causes confusion and duplicate PRs, cluttering the review process.
Quick: Is it safe to force push anytime you want without checking? Commit yes or no.
Common Belief:Force pushing is always safe and can be done anytime to update PRs.
Tap to reveal reality
Reality:Force pushing rewrites history and can overwrite others' work if not done carefully; use --force-with-lease and communicate with your team.
Why it matters:Misusing force push can cause lost commits and disrupt collaboration.
Quick: Do all feedback comments require code changes? Commit yes or no.
Common Belief:Every comment on a PR means you must change your code.
Tap to reveal reality
Reality:Some comments are suggestions, questions, or approvals that don't require changes.
Why it matters:Misunderstanding this leads to unnecessary work and delays.
Quick: Does rebasing your branch always make your PR harder to review? Commit yes or no.
Common Belief:Rebasing always confuses reviewers and should be avoided.
Tap to reveal reality
Reality:When done properly, rebasing cleans history and can make PRs easier to understand.
Why it matters:Avoiding rebasing due to fear can lead to messy commit histories and harder maintenance.
Expert Zone
1
Reviewers often look at the diff between the latest commit and the base branch, so small fixup commits can clutter the review unless squashed.
2
Force pushing with --force-with-lease is safer than plain --force because it checks if the remote branch changed before overwriting.
3
Some teams prefer rebasing to keep a linear history, while others prefer merge commits; knowing your team's policy is crucial.
When NOT to use
Avoid force pushing on shared branches where others also push; use merge commits instead. If your team prefers a merge-based workflow, do not rebase PR branches. For very large or complex PRs, consider breaking feedback into smaller chunks rather than updating all at once.
Production Patterns
In professional teams, developers often create feature branches, submit PRs, and iterate with feedback by pushing fixup commits. Before merging, they rebase interactively to clean history and then force push. Automated CI checks run on each update. Teams use draft PRs to gather early feedback without final review.
Connections
Version Control Systems
Builds-on
Understanding how git tracks changes and branches helps grasp why PR updates work by pushing commits to branches.
Code Review Process
Same pattern
Handling PR feedback is a practical application of the broader code review process, emphasizing communication and iteration.
Iterative Design in Product Development
Similar pattern
Just like product design improves through cycles of feedback and updates, PR handling is a technical version of iterative improvement.
Common Pitfalls
#1Ignoring feedback comments or not responding to them.
Wrong approach:No changes made after feedback; PR stays the same. $ git push origin feature-branch // No new commits addressing feedback
Correct approach:$ git add updated_file $ git commit -m "Fix issues from review" $ git push origin feature-branch
Root cause:Misunderstanding that feedback requires action or fear of making changes.
#2Force pushing without --force-with-lease or warning the team.
Wrong approach:$ git push --force origin feature-branch
Correct approach:$ git push --force-with-lease origin feature-branch
Root cause:Lack of awareness about safer force push options and team communication.
#3Creating a new PR for every update instead of updating the existing one.
Wrong approach:After feedback, push changes to a new branch and open a new PR each time.
Correct approach:Push changes to the same branch linked to the original PR to update it.
Root cause:Not understanding that PRs track branches, not individual commits.
Key Takeaways
A Pull Request is a living document that updates automatically when you push new commits to its branch.
Handling PR feedback well means reading comments carefully, making clear code changes locally, and pushing updates to the same branch.
Using interactive rebase and force push carefully helps keep commit history clean and collaboration smooth.
Misusing force push or misunderstanding feedback types can cause lost work and slow down the team.
Good PR feedback handling is like an iterative conversation that improves code quality and team trust.