LoginSignup
153
151

More than 5 years have passed since last update.

GitHub の Issue をあとから Pull Request にする (あとからコードを添付する)

Last updated at Posted at 2012-12-26

hub(1) を使うと簡単にできる。

追記1: コメント欄より。

  • Issue を Pull Request にすると label が外れる(Pull Request には label がつけられないので)
  • Asssign 状態は変化しない

追記2: この機能は hub コマンドの master ブランチでは削除されている(おそらく次期リリースで無くなる) GitHub も将来 API (v4) からこの機能を無くすつもりのようだ。参考

例: pullreq ブランチから master ブランチに対して Pull Request を送りたいが、その際に既存の Issue#123 にコードを添付したい

$ git checkout -b pullreq
$ commit; commit; commit;
$ hub pull-request -i 123
https://github.com/kyanny/test/pull/123

Organization アカウントの中のリモートブランチ同士で上記の操作を行いたいとき

Organization アカウントを使っていると remote URL が自分自身のアカウントと違うものになる。このとき hub(1) は me:branch から organization:master へ Pull Request しようとする (自分のアカウントに fork してきたリモートブランチが存在しないといけない)

$ hub pull-request -i 123
Error creating pull request: Unprocessable Entity (HTTP 422)
field 'head_sha' is missing
field 'base_sha' is missing
No commits between our-company-organization:master and kyanny:my-ultra-super-excellent-feature-branch

これを回避するには -h オプションを利用する (organization:branch という表記に注意) 下の例は our-company-organization:master から our-company-organization:my-ultra-super-excellent-feature-branch への差分を Pull Request として Issue#177 に添付する。

$ hub pull-request -i 177 -h our-company-organization:my-ultra-super-excellent-feature-branch
https://github.com/our-company-organization/very-very-cool-project/pull/123

これで fork いらずでさくさくと Issue にコードを添付できる。

参考

defunkt/hub
https://github.com/defunkt/hub

git - How do you attach a new pull request to an existing issue on github? - Stack Overflow
http://stackoverflow.com/questions/4528869/how-do-you-attach-a-new-pull-request-to-an-existing-issue-on-github

153
151
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
153
151