Read Anthropic’s case study about Graphite Reviewer

How to checkout and review a pull request locally

Sara Verdi
Sara Verdi
Graphite software engineer


Note

This guide explains this concept in vanilla Git. For Graphite documentation, see our CLI docs.


Reviewing pull requests locally allows developers to run tests, check for integration issues, and evaluate code in their own development environment. This guide provides a comprehensive overview of checking out and reviewing pull requests locally using Git commands and the Graphite CLI, with examples and best practices.

  • Git installed on your machine.
  • Graphite CLI installed. For installation, use the command:
Terminal
brew install withgraphite/tap/graphite
gt --version
  1. Fetch the pull request: Use Git to fetch the pull request you want to review. If you know the pull request number, you can fetch it directly:

    Terminal
    git fetch origin pull/ID/head:BRANCHNAME

    Replace ID with the pull request number and BRANCHNAME with the name you want to assign to the new branch.

  2. Checkout the branch: After fetching the pull request, check it out like any other branch:

    Terminal
    git checkout BRANCHNAME

Graphite CLI simplifies managing stacks of changes, which includes checking out pull requests.

Checkout the pull request: Use the Graphite CLI to checkout the pull request directly:

Terminal
gt checkout PR_BRANCH_NAME

Replace PR_BRANCH_NAME with the name of the branch associated with the pull request.

After checking out the pull request, you can start your review process:

  1. Run local tests: Ensure that the changes pass all local tests.

  2. Code review: Go through the code changes. Look for any code smells, styling errors, or potential bugs that might have been overlooked.

  3. Use Graphite's features: If the pull request is part of a stack, you might find it useful to navigate through the stack using:

    Terminal
    gt log

    This command shows you the stack of changes and allows easy navigation using gt up or gt down.

Once you're done with your review:

  1. Commit any changes: If you make any changes during your review, commit them:

    Terminal
    git commit -am "Review adjustments"
  2. Push your changes: If you're collaborating on a fork or a shared repository, push your adjustments:

    Terminal
    git push origin BRANCHNAME
  3. Leave feedback on GitHub: Post your comments and approval or request changes directly on the GitHub pull request page.

Or you can do this with Graphite:

  1. Once you’ve made your changes and are ready to git add && git commit, you can run:
Terminal
gt modify

Your changes will be amended to the existing commit.

  1. Now that you’ve committed your changes, you can push them up:
Terminal
gt submit

Checking out and reviewing pull requests locally is an essential skill for developers. Using Git and Graphite CLI can simplify the process, making it easier to manage changes and ensure high code quality. Remember to utilize Graphite's capabilities for managing stacks, which can simplify navigating complex changes.

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

Graphite
Git stacked on GitHub

Stacked pull requests are easier to read, easier to write, and easier to manage.
Teams that stack ship better software, faster.

Or install our CLI.
Product Screenshot 1
Product Screenshot 2