What is PR in GitHub?

Asked 6 hours ago Updated 6 hours ago 26 views

1 Answer


0

In GitHub, PR stands for Pull Request.

A Pull Request is a way to propose changes you've made in one branch and ask for those changes to be reviewed and merged into another branch (usually main or master).

How a Pull Request Works

  • Create a new branch
    • Example: feature/login-page
  • Make your changes
    • Add new features, fix bugs, or update documentation.
  • Commit your changes
git add .
git commit -m "Add login page"
  • Push the branch to GitHub
git push origin feature/login-page
  • Open a Pull Request
    • On GitHub, compare feature/login-page with main.
    • Add a title and description explaining the changes.
    • Request reviewers if needed.
  • Code Review
    • Team members review the code.
    • They can approve it, request changes, or leave comments.
  • Merge the PR
    • Once approved and all checks pass, the Pull Request is merged into the target branch.

Why Use Pull Requests?

  • Enables code reviews before merging.
  • Encourages team collaboration.
  • Runs automated tests using GitHub Actions.
  • Keeps a record of discussions and decisions.
  • Helps prevent bugs from reaching the main branch.

Example

Suppose your repository has this structure:

main
 ├── README.md
 └── app.py

You create a branch:

feature/dark-mode

After adding dark mode, you open a Pull Request:

feature/dark-mode  ─────────▶  main
          (Pull Request)

Your teammates review the changes, suggest improvements if necessary, and once approved, the PR is merged into main.

Common Pull Request Terms

  • Base branch: The branch you want to merge into (e.g., main).
  • Compare branch: The branch containing your changes.
  • Reviewer: A person who checks your code.
  • Approval: Confirmation that the changes are acceptable.
  • Merge: Incorporating the changes into the base branch.
  • Conflict: When changes in two branches overlap and must be resolved before merging.

In short, a Pull Request is GitHub's collaboration mechanism for reviewing, discussing, and safely merging code changes into a project.
 

Write Your Answer