Read Anthropic’s case study about Graphite Reviewer

Guide to GitHub PR labels

Sara Verdi
Sara Verdi
Graphite software engineer
Try Graphite

Pull request (PR) labels in GitHub serve as a tool for categorizing and prioritizing changes. They help streamline workflows and make it easier to filter and find specific pull requests within a repository. This guide will delve into how to efficiently use PR labels, including adding, changing, and managing them through the GitHub interface and API.

Adding labels to your pull requests in GitHub is straightforward:

  1. Navigate to the pull request on GitHub.
  2. On the right side of the pull request page, find the "Labels" section.
  3. Click on the "gear" icon to open the label menu.
  4. Select the labels you want to apply or create a new one by typing the label name and pressing "Enter."

Graphite's PR inbox also enhances label management by allowing you to configure and view labels as part of your customized workflow. It acts like an email client for your PRs, helping you stay organized and pinpoint which PRs need your attention based on the labels applied.

To change existing labels on a pull request:

  1. Open the pull request on GitHub.
  2. Click on the "Labels" section on the right.
  3. You can remove a label by clicking the "x" next to the label's name.
  4. Add new labels by clicking on the gear icon and selecting or creating new labels.

The GitHub API also offers extensive capabilities for managing pull request labels programmatically. Here's a basic example of how to add a label to a pull request using the GitHub API:

Terminal
curl -X POST -H "Authorization: token YOUR_GITHUB_TOKEN" -H "Accept: application/vnd.github.v3+json" \
-d '{"labels": ["bug", "urgent"]}' \
"https://api.github.com/repos/USERNAME/REPOSITORY/issues/PULL_REQUEST_NUMBER/labels"

This command adds the "bug" and "urgent" labels to the specified pull request. Make sure to replace YOUR_GITHUB_TOKEN, USERNAME, REPOSITORY, and PULL_REQUEST_NUMBER with your actual data.

Graphite's PR inbox can further enhance your label management. It allows you to:

  • View pull requests by label across your default repositories.
  • Set up custom sections in your inbox based on specific labels, making it easier to prioritize and manage your review workload.

For instance, you could create a section for all PRs labeled as "urgent" or separate sections for "bug" and "feature" labels. This customization can be shared with teammates, ensuring everyone is aligned on priorities and workflows. Plus, Graphite's ability to handle stacked pull requests, which are easier to read and manage, also benefits from effective label use. Teams using Graphite with well-defined label systems can ship better software faster.

Using labels effectively in GitHub can transform how you handle code reviews, making your process more efficient. Incorporating Graphite's PR inbox can further enhance this capability to ensure your team remains on top of each and every critical change.

Git inspired
Graphite's CLI and VS Code extension make working with Git effortless.
Learn more

Built for the world's fastest engineering teams, now available for everyone