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.

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:
| Method | What it does |
|---|---|
| Create a merge commit | Keeps every commit and adds a merge commit |
| Squash and merge | Combines the branch's commits into one new commit |
| Rebase and merge | Replays 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.
-
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 -
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-readmein the branch menu first. Check that the base ismainand the compare branch isimprove-readme. Write a title and a description saying what the change does and why, then click Create pull request. -
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.
-
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 pushRefresh 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.
-
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.
-
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 -aBefore the pull,
git statusstill 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 -alists onlymain,origin/mainand possiblyorigin/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 see | Likely cause | Next step |
|---|---|---|
| No Compare & pull request banner | The banner is not shown, or the push failed | Choose the branch in the branch menu, or check the push output |
| The pull request does not show the new commit | The commit was not pushed, or was pushed to another branch | git status, then git push on improve-readme |
| The merge button is disabled | The base branch has conflicting changes, or the repository requires checks or approvals | Read the message in the merge box |
git branch -d says is not fully merged | A squash or rebase merge, or the pull was skipped | git pull; if git diff main improve-readme prints nothing, use -D |
Local main lacks the change | You have not pulled since the merge | git pull |
-
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
- You merged a pull request on GitHub five minutes ago. Your local
git logonmaindoes not show it. Why, and what do you run? - 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
- The merge happened in the repository on GitHub. Your clone only learns
about it when it fetches, so
git switch mainandgit pullbring the merge into your localmain. - 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.