LoginSignup
396

More than 3 years have passed since last update.

posted at

updated at

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

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
396