379
Help us understand the problem. What are the problem?

More than 1 year has passed since last update.

posted at

updated at

Organization

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

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
Sign upLogin
379
Help us understand the problem. What are the problem?