Git Pull Requests

Propose and review changes on GitHub.

✍️ 2 exercises in this lesson

A pull request (PR) asks to merge a branch into another, usually main. It is where teams review code.

  1. Create a branch and commit your work.
  2. Push the branch: git push -u origin feature-search
  3. On GitHub, click Compare & pull request, describe the change and request reviewers.
  4. Address review comments by pushing more commits.
  5. When approved and checks pass, merge the PR and delete the branch.

The GitHub CLI can do it from the terminal: gh pr create.

Key Takeaways: Git Pull Requests

Mastering Git Pull Requests helps you write clean and reliable Git code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.

Git Pull Requests Code Example

Git
git switch -c feature-search
# ...edit files...
git commit -am "Add search bar"
git push -u origin feature-search
gh pr create --title "Add search bar" --body "Adds a search bar to the header."
Output
https://github.com/alikhan/my-project/pull/1
Run this example on your own computer. The "Get Started" lesson shows how to set it up.

Git Pull Requests Practice Exercises

Check what you learned in “Git Pull Requests”.

/ 2 solved
Fill in the blank

Create a pull request with the GitHub CLI.

gh pr 
✓ Correct! Not quite. Try again.
Multiple choice

What is a pull request mainly used for?

✓ Correct! Not quite. Try again.
to save your exercise progress.
Finished this lesson?
Mark it complete to track your progress.

Stuck on something?

Ask the community in the CodesInTech forum.

Need a developer?

Learning on your own is great — and when you need professional help, our team builds custom software, websites and mobile apps for clients worldwide.

Explore Our Services