Help us understand the problem. What is going on with this article?

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

概要

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

https://help.github.com/articles/checking-out-pull-requests-locally/

tarr1124
plaid
CXプラットフォーム「KARTE」の開発・運営、EC特化型メディア「Shopping Tribe」の企画・運営、CX特化型メディア「XD(クロスディー)」の企画・運営
https://plaid.co.jp/
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
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  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
ユーザーは見つかりませんでした