540
398

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

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

Last updated at Posted at 2014-12-15

#概要
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/

540
398
4

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
  3. You can use dark theme
What you can do with signing up
540
398

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?