Git Foundations / Optional: Review on a Hosting Service

Optional: open and update a pull request

Lesson 33 of 33. Open to read. No account needed.

What a Pull Request Is

In the remotes module, Asha and Ravi merged feature branches into main themselves. On most teams, a change goes through a pull request first: a proposal, on the hosting service, to merge one branch into another. It shows the commits and the changed lines, and it gives teammates a place to discuss and review the change before anyone merges it.

A pull request has:

  • A base branch, where the change should go, usually main.
  • A compare branch, sometimes called the head branch, holding the change.
  • A title and description explaining what the change does and why.
  • A conversation with comments, including comments on specific lines.

The interface changes from time to time. If a button below has moved, GitHub's documentation, linked in the references, shows the current steps.

Six steps; filled boxes run in your clone and white boxes happen on GitHub. 1. Push the branch. 2. Open a pull request with Compare and pull request. 3. Review with comments on Files changed. 4. Update by committing and pushing again. 5. Merge, then delete the branch. 6. Sync with git pull, then git fetch --prune. Steps 3 and 4 repeat until the reviewer is satisfied.

Updating a Pull Request

A pull request follows its branch. To respond to review, you do not open a new pull request: you commit on the same branch and push. The new commits appear in the pull request, and reviewers can look at what changed.

Merging and Merge Methods

When the change is approved, someone merges it from the merge box at the bottom of the pull request. GitHub offers up to three methods:

MethodWhat it does
Create a merge commitKeeps every commit and adds a merge commit
Squash and mergeCombines the branch's commits into one new commit
Rebase and mergeReplays the commits onto the base branch, one by one

A repository may be set up to offer only some of them. After merging, GitHub offers to delete the branch, which keeps the branch list tidy.

After Merging: Sync Your Clone

The merge happened on GitHub, so your clone does not know about it yet: your local main is behind until you pull. Then tidy up:

git switch main
git pull
git fetch --prune
git branch -d <branch>

git fetch --prune drops origin/<branch>, which GitHub deleted. After a squash or rebase merge, the branch's original commits are not on main, so git branch -d refuses with is not fully merged. Check that main now has the change, for example with git diff main <branch> printing nothing, then delete it with -D.

Exercise: Take a Change Through Review

You will propose an improvement to the README, respond to a review comment, and merge the result.

Starting state: the hosted practice repository from the previous lesson, with your local clone at ~/git-practice/hosted-practice and origin pointing at GitHub. If you already deleted it, repeat that lesson's exercise first.

Working alone, you play both author and reviewer. On a team, a teammate would write the review comments.

  1. Make the change on a branch and push it:

    cd ~/git-practice/hosted-practice
    git switch main
    git pull
    git switch -c improve-readme
    cat >> README.md <<'EOF'
    
    ## How to use it
    
    Clone it, make a branch, and open a pull request.
    EOF
    git commit -am "Explain how to use the repository"
    git push -u origin improve-readme
    
  2. Open the pull request. On the repository's page on GitHub, a banner offers Compare & pull request for the branch you just pushed; click it. If you do not see the banner, choose improve-readme in the branch menu first. Check that the base is main and the compare branch is improve-readme. Write a title and a description saying what the change does and why, then click Create pull request.

  3. Review it. Open the Files changed tab, hover over the line about cloning, click the comment icon, write "Please add an example branch name." and click Comment.

  4. Respond to the review with a new commit on the same branch:

    cat >> README.md <<'EOF'
    
    For example: git switch -c fix-typo
    EOF
    git commit -am "Add an example branch name"
    git push
    

    Refresh the pull request: the conversation now lists the new commit, and Files changed includes the example line. You can reply to the comment to say it is done.

  5. Merge it. At the bottom of the pull request, use Merge pull request (the "Create a merge commit" method), then Confirm merge. Then click the button to delete the branch.

  6. Sync your clone and clean up:

    git switch main
    git status
    git pull
    git log --oneline --graph
    git fetch --prune
    git branch -d improve-readme
    git branch -a
    

    Before the pull, git status still says your branch is up to date: your clone has not asked GitHub since the merge. The pull brings the merge commit and both of your commits. After pruning, git branch -a lists only main, origin/main and possibly origin/HEAD.

Success: the pull request is merged, your local main contains both commits, and improve-readme is gone from your clone and from GitHub.

If something differs:

What you seeLikely causeNext step
No Compare & pull request bannerThe banner is not shown, or the push failedChoose the branch in the branch menu, or check the push output
The pull request does not show the new commitThe commit was not pushed, or was pushed to another branchgit status, then git push on improve-readme
The merge button is disabledThe base branch has conflicting changes, or the repository requires checks or approvalsRead the message in the merge box
git branch -d says is not fully mergedA squash or rebase merge, or the pull was skippedgit pull; if git diff main improve-readme prints nothing, use -D
Local main lacks the changeYou have not pulled since the mergegit pull
  1. When you have finished the module, delete the hosted repository (Settings, then Delete this repository in the "Danger Zone") and the local folder:

    cd ~/git-practice
    ls
    rm -rf hosted-practice
    ls
    

Independent task: before deleting anything, run a second, small pull request on your own: add a line to the README on a new branch, open a pull request, merge it with Squash and merge this time, and bring your local main up to date. Delete the local branch and explain why git branch -d behaves differently from step 6.

Check Your Understanding

  1. You merged a pull request on GitHub five minutes ago. Your local git log on main does not show it. Why, and what do you run?
  2. A reviewer asks for a change. Do you open a new pull request?

Answer and Reasoning

Independent task

After the squash merge on GitHub:

git switch main
git pull
git fetch --prune
git branch -d <branch>
git diff main <branch>
git branch -D <branch>

git branch -d refuses with is not fully merged: squash and merge created a single new commit on main, so your branch's original commit is not part of main's history. git diff main <branch> printing nothing confirms that the content is on main, so deleting with -D loses nothing. In step 6 the merge commit included your commits, so -d succeeded.

Understanding check

  1. The merge happened in the repository on GitHub. Your clone only learns about it when it fetches, so git switch main and git pull bring the merge into your local main.
  2. No. Commit the change on the same branch and push; the pull request updates to include the new commit, and the discussion stays in one place.

References

Study this course with an account

Course access adds revision notes, the Quick Reference, saved progress, bookmarks and your own notes.

INR 99 plus 18% GST. 90 days of online access. No auto-renewal.

See course access

This website is operated by VECTAMETRIC EDTECH (OPC) PRIVATE LIMITED, operating as Vectametric.

Corporate Identity Number (CIN): U85499KA2026OPC229822. GSTIN: 29AAMCV8281D1ZS. Registered office: RS NO/38/2A/1 BASTAND, ROAD MAHANTESH NAGAR, Ramdurg, Ramdurg, Belgaum- 591123, Karnataka.

Queries and grievances: Prajval Honnungar, Grievance Officer and Data Protection Contact.

Telephone: +91 94800 09310. Support: support@vectametric.com. Grievances: support@vectametric.com.

Copyright 2026 VECTAMETRIC EDTECH (OPC) PRIVATE LIMITED. All rights reserved.

Vectametric home · Roadmaps · Vecta IT Exams · Vecta Government Exams · Vecta Banking & Finance Exams · Vecta Entrance Exams · About us · Contact · Privacy Policy · Terms and Conditions · No-Refund Policy