{"id":824,"date":"2022-05-06T02:28:33","date_gmt":"2022-05-06T02:28:33","guid":{"rendered":"https:\/\/blog.ngocha.biz\/?p=824"},"modified":"2022-05-06T02:28:33","modified_gmt":"2022-05-06T02:28:33","slug":"checkout-git-pull-request","status":"publish","type":"post","link":"https:\/\/blog.ngocha.biz\/?p=824","title":{"rendered":"How to Checkout Git Pull Request in Three Easy Steps"},"content":{"rendered":"<p>In this blog, you will learn <strong>how to checkout a git pull request<\/strong> using step-by-step instructions.<\/p>\n<h2 id=\"git-checkout-pull-request-steps\">Git Checkout Pull Request Steps<\/h2>\n<p>You might need to check out an unapproved pull request for several reasons. In most cases, the automated CI\/CD workflow takes care of testing the changes. However, when there is a pull request for a breaking change, you might want to test the changes separately before merging them to the desired branch.<\/p>\n<h2 id=\"step-1-get-the-pull-request-number\">Step 1: Get the Pull Request Number<\/h2>\n<p>First, <strong>get the pull request number<\/strong> from the Pull request details. It you are using Github, you can easily get the pull request number from the GUI as shown below.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-5-61.png\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"611\" height=\"522\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/image-5-61.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-5-61.png 611w\"><\/figure>\n<p>If you are using <a href=\"https:\/\/github.com\/cli\/cli?ref=devopscube.com\" rel=\"noreferrer noopener\">Github CLI<\/a>, you can get the PR number by executing the following command from the repo directory.<\/p>\n<pre><code>gh pr list<\/code><\/pre>\n<h2 id=\"step-2-fetch-origin-with-pull-request-number\">Step 2:  Fetch origin With Pull Request number<\/h2>\n<p>Now that you have the PR number, you can <strong>fetch all the changes locally <\/strong>from the origin to a local git branch using the following command.<\/p>\n<p>Replace <code>15<\/code> with your PR number and <code>test-branch<\/code> with the desired branch name.<\/p>\n<pre><code>git fetch origin pull\/15\/head:test-branch<\/code><\/pre>\n<h2 id=\"step-3-checkout-the-pull-request-local-branch\">Step 3: Checkout the Pull Request Local Branch<\/h2>\n<p>Now checkout the <code>test-branch<\/code> where you have all the changes from the pull request.<\/p>\n<pre><code>git checkout test-branch<\/code><\/pre>\n<p>With this local test branch, you can run all your tests and even try making changes. Once you are done with the testing, you can review the pull requests again if changes are required and merge them to the desired branch.<\/p>\n<h2 id=\"conclusion\">Conclusion<\/h2>\n<p>You can <strong>checkout a git pull request<\/strong> in three easy steps as shown in this article. If you are building a CI\/CD pipeline for application or infrastructure code, always integrate automated testing on every PR so that you dont have to manually test it and avoid wrong configurations getting merged to deployment branches.<\/p>\n<p>Also, learn how to <a href=\"https:\/\/devopscube.com\/checkout-clone-specific-git-commit-id-sha\/\" rel=\"noreferrer noopener\">checkout a specific git commit<\/a> and how to <a href=\"https:\/\/devopscube.com\/checkout-clone-git-tags\/\" rel=\"noreferrer noopener\">checkout a git tag<\/a>.<\/p>\n<hr>\n<p><strong>Ngu\u1ed3n:<\/strong> <a href=\"https:\/\/devopscube.com\/checkout-git-pull-request\/\" target=\"_blank\" rel=\"noopener noreferrer\">How to Checkout Git Pull Request in Three Easy Steps \u2014 DevOpsCube<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Source: https:\/\/devopscube.com\/checkout-git-pull-request\/<\/p>\n","protected":false},"author":1,"featured_media":825,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-824","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops"],"_links":{"self":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts\/824","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=824"}],"version-history":[{"count":0,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts\/824\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/media\/825"}],"wp:attachment":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=824"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=824"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=824"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}