{"meta":{"title":"Checking out pull requests locally","intro":"Check out pull requests locally to resolve merge conflicts, test changes, or modify code.","product":"Pull requests","breadcrumbs":[{"href":"/en/pull-requests","title":"Pull requests"},{"href":"/en/pull-requests/how-tos","title":"How-tos"},{"href":"/en/pull-requests/how-tos/review-pull-requests","title":"Review pull requests"},{"href":"/en/pull-requests/how-tos/review-pull-requests/checking-out-pull-requests-locally","title":"Check out a PR locally"}],"documentType":"article"},"body":"# Checking out pull requests locally\n\nCheck out pull requests locally to resolve merge conflicts, test changes, or modify code.\n\n> \\[!NOTE]\n> Pull request authors can give upstream repository maintainers, or people with push access to the upstream repository, permission to make commits to their pull request's compare branch in a user-owned fork. See [Allowing changes to a pull request branch created from a fork](/en/pull-requests/how-tos/work-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork).\n\n## Modifying an active pull request locally\n\n<div class=\"ghd-tool webui\">\n\n1. Under your repository name, click **<svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-git-pull-request\" aria-label=\"git-pull-request\" role=\"img\"><path d=\"M1.5 3.25a2.25 2.25 0 1 1 3 2.122v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.25 2.25 0 0 1 1.5 3.25Zm5.677-.177L9.573.677A.25.25 0 0 1 10 .854V2.5h1A2.5 2.5 0 0 1 13.5 5v5.628a2.251 2.251 0 1 1-1.5 0V5a1 1 0 0 0-1-1h-1v1.646a.25.25 0 0 1-.427.177L7.177 3.427a.25.25 0 0 1 0-.354ZM3.75 2.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm0 9.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm8.25.75a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Z\"></path></svg> Pull requests**.\n2. In the list of pull requests, click the pull request you want to modify.\n3. To choose where you want to open the pull request, select the **<svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-code\" aria-label=\"code\" role=\"img\"><path d=\"m11.28 3.22 4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L13.94 8l-3.72-3.72a.749.749 0 0 1 .326-1.275.749.749 0 0 1 .734.215Zm-6.56 0a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042L2.06 8l3.72 3.72a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L.47 8.53a.75.75 0 0 1 0-1.06Z\"></path></svg> Code** dropdown and click one of the tabs.\n\n   ![Screenshot of a pull request title. A button with an arrow indicating a dropdown menu, labeled \"Code,\" is outlined in dark orange.](/assets/images/help/pull_requests/open-with-button.png)\n\n</div>\n\n<div class=\"ghd-tool cli\">\n\n> \\[!NOTE]\n> To learn more about GitHub CLI, see [About GitHub CLI](/en/github-cli/github-cli/about-github-cli).\n\nTo check out a pull request locally, use the `gh pr checkout` subcommand. Replace `PULL-REQUEST` with the number, URL, or head branch of the pull request.\n\n```shell\ngh pr checkout PULL-REQUEST\n```\n\n</div>\n\n## Modifying an inactive pull request locally\n\nIf a pull request’s author is unresponsive to requests or has deleted their fork, the changes proposed in that pull request can still be merged through a new pull request. However, if you want to make changes, you need to take additional steps to update the pull request.\n\nAfter a pull request is opened, GitHub stores all of the changes remotely. Commits in a pull request are available in a repository even before the pull request is merged. You can fetch an open pull request and recreate it as your own.\n\nAnyone can work with a previously opened pull request to continue working on it, test it, or open a new pull request with additional changes.\n\n1. Under your repository name, click **<svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-git-pull-request\" aria-label=\"git-pull-request\" role=\"img\"><path d=\"M1.5 3.25a2.25 2.25 0 1 1 3 2.122v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.25 2.25 0 0 1 1.5 3.25Zm5.677-.177L9.573.677A.25.25 0 0 1 10 .854V2.5h1A2.5 2.5 0 0 1 13.5 5v5.628a2.251 2.251 0 1 1-1.5 0V5a1 1 0 0 0-1-1h-1v1.646a.25.25 0 0 1-.427.177L7.177 3.427a.25.25 0 0 1 0-.354ZM3.75 2.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm0 9.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm8.25.75a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Z\"></path></svg> Pull requests**.\n\n2. In the **Pull Requests** list, click the pull request you want to merge.\n\n3. Find the ID number of the inactive pull request. This is the sequence of digits right after the pull request's title.\n\n   ![Screenshot of the title of a pull request. The pull request's ID number is outlined in dark orange.](/assets/images/help/pull_requests/pull-request-id-number.png)\n\n4. Open your terminal or Git Bash.\n\n5. Fetch the reference to the pull request based on its ID number. This creates a new branch. Use the pull request ID and the name of the local branch you want to create in the command.\n\n   ```shell\n   git fetch origin pull/ID/head:BRANCH_NAME\n   ```\n\n6. Switch to the new branch that's based on this pull request:\n\n   ```shell\n   [main] $ git switch BRANCH_NAME\n   > Switched to a new branch 'BRANCH_NAME'\n   ```\n\n7. Make any needed changes to this branch. You can run local tests or merge other branches into the branch.\n\n8. When you're ready, push the new branch:\n\n   ```shell\n   [pull-inactive-pull-request] $ git push origin BRANCH_NAME\n   > Counting objects: 32, done.\n   > Delta compression using up to 8 threads.\n   > Compressing objects: 100% (26/26), done.\n   > Writing objects: 100% (29/29), 74.94 KiB | 0 bytes/s, done.\n   > Total 29 (delta 8), reused 0 (delta 0)\n   > To https://github.com/USERNAME/REPOSITORY.git\n   >  * [new branch]      BRANCH_NAME -> BRANCH_NAME\n   ```\n\n9. Create a new pull request with your new branch.\n\n## Error: Failed to push some refs\n\nThe remote `refs/pull/` namespace is *read-only*. If you try to push commits there, you'll see this error:\n\n```shell\n! [remote rejected] HEAD -> refs/pull/1/head (deny updating a hidden ref)\nerror: failed to push some refs to 'git@github.local:USERNAME/REPOSITORY.git'\n```\n\n> \\[!TIP]\n> When you remove or rename a remote reference, calls to `git-remote` do not affect your local `refs/pull/origin/` namespace."}