Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
348
Help us understand the problem. What is going on with this article?
@tarr1124

Githubで特定のpull requestをローカルに持ってくる

More than 1 year has passed since last update.

概要

OSSのメンテナっぽいことをやるとき、githubで特定のpull requestの正当性を確認したいということがあると思う。ブランチチェックアウトすれば良くね?って単純に考えていたけど、結構面倒くさかったので、メモっとく。

やり方

とりあえず、repositoryをcloneして、branchを見てみる。

$ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/feature/support_gemfile
  remotes/origin/master
  remotes/origin/test_1.0.0

pull requestのbranchは入っていない。

下記を参照すると、どうやらこのようにやれば良いらしい。
Checking out pull requests locally - User Documentation

$ git fetch origin pull/ID/head:BRANCHNAME

今回の場合は、25になる。
pr.png

fetchしてみる

$ git fetch origin pull/25/head:abolish_ruby_server_dir
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 5 (delta 1), reused 3 (delta 1)
Unpacking objects: 100% (5/5), done.
From https://github.com/roma/roma
 * [new branch]      refs/pull/25/head -> abolish_ruby_server_dir

checkoutしてみる

$ git branch -a
  abolish_ruby_server_dir
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/feature/support_gemfile
  remotes/origin/master
  remotes/origin/test_1.0.0
$ git checkout abolish_ruby_server_dir
Switched to branch 'abolish_ruby_server_dir'

いけた。

Reference

348
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
tarr1124
plaid
CXプラットフォーム「KARTE」の開発・運営、EC特化型メディア「Shopping Tribe」の企画・運営、CX特化型メディア「XD(クロスディー)」の企画・運営

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
348
Help us understand the problem. What is going on with this article?