# pull request の作成

リポジトリ内のコードに対する変更を提案するプル要求を作成します。

pull request の新しいブランチを作成するが、リポジトリへの書き込みアクセス許可がない場合は、まずリポジトリをフォークできます。 「[Creating a pull request from a fork](/ja/enterprise-cloud@latest/pull-requests/how-tos/create-pull-requests/creating-a-pull-request-from-a-fork)」と「[フォーク](/ja/enterprise-cloud@latest/pull-requests/reference/forks)」を参照してください。

pull request を作成するときに、変更をマージするブランチを指定できます。 プル要求は、2 つの異なるブランチ間でのみ開くことができます。

> \[!NOTE]
> パブリック リポジトリの pull request を開くには、ヘッドまたはソース ブランチへの書き込みアクセス権が必要です。または、organization が所有するリポジトリの場合は、pull request を開くリポジトリを所有する organization のメンバーである必要があります。

プル要求を問題にリンクして、修正プログラムが進行中であることを示し、pull request がマージされたときに問題を自動的に閉じます。 詳しくは、「[プルリクエストを課題にリンクする](/ja/enterprise-cloud@latest/issues/tracking-your-work-with-issues/using-issues/linking-a-pull-request-to-an-issue)」をご覧ください。

## プルリクエストの作成

<div class="ghd-tool webui">

1. GitHub で、リポジトリのメイン ページに移動します。

2. \[Branch] メニューで、自分のコミットが含まれるブランチを選択します。

   ![リポジトリのメイン ページにあるブランチ ドロップダウン メニューのスクリーンショット。](/assets/images/help/pull_requests/branch-dropdown.png)

3. ファイルの一覧の上にある黄色のバナーで、 **\[比較と pull request]** をクリックして、関連付けられているブランチの pull request を作成します。

   ![ファイルの一覧の上にあるバナーのスクリーンショット。](/assets/images/help/pull_requests/pull-request-compare-pull-request.png)

4. \_基本\_ブランチドロップダウン メニューを使用して、変更をマージするブランチを選択します。 次に、\[ *ブランチの比較* ] ドロップダウン メニューを使用して、変更を行ったトピック ブランチを選択します。

5. プルリクエストのタイトルと説明を入力します。

6. レビューの準備が完了している pull request を作成するには、 **\[pull request の作成]** をクリックします。
   ドラフトの pull request を作成するには、ドロップダウンを使用して、 **\[ドラフトの pull request の作成]** を選択し、 **\[ドラフトの pull request]** をクリックします。 組織のメンバーである場合は、組織の所有者から下書きプル要求へのアクセスを要求することが必要になることがあります。 「[Pull Request](/ja/enterprise-cloud@latest/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests#draft-pull-requests)」をご覧ください。

> \[!TIP]
> pull request を作成したら、[提案された変更のレビュー](/ja/enterprise-cloud@latest/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/reviewing-proposed-changes-in-a-pull-request)を特定の人に依頼できます。 詳しくは、「[プルリクエストレビューを依頼する](/ja/enterprise-cloud@latest/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/requesting-a-pull-request-review)」をご覧ください。

pull request が確認されたら、リポジトリにマージできます。 「[Merging a pull request](/ja/enterprise-cloud@latest/pull-requests/how-tos/merge-and-close-pull-requests/merging-a-pull-request)」を参照してください。

</div>

<div class="ghd-tool cli">

> \[!NOTE]
> GitHub CLI の詳細については、「[GitHub CLI について](/ja/enterprise-cloud@latest/github-cli/github-cli/about-github-cli)」を参照してください。

pull request を作成するには、`gh pr create` サブコマンドを使用します。

```shell
gh pr create
```

pull request を個人に割り当てるには、`--assignee` または `-a` フラグを使用します。 pull request を自己割り当てするために `@me` を使用できます。

```shell
gh pr create --assignee "@octocat"
```

pull request をマージするブランチを指定するには、`--base` または `-B` フラグを使用します。 pull request のコミットを含むブランチを指定するには、`--head` または `-H` フラグを使用します。

```shell
gh pr create --base my-base-branch --head my-changed-branch
```

新しい pull request のタイトルと本文を含めるには、`--title` と `--body` フラグを使用します。

```shell
gh pr create --title "The bug is fixed" --body "Everything works again"
```

pull request をドラフトとしてマークするには、`--draft` フラグを使用します。

```shell
gh pr create --draft
```

新しいプル要求にラベルまたはマイルストーンを追加するには、 `--label` フラグと `--milestone` フラグを使用します。

```shell
gh pr create --label "bug,help wanted" --milestone octocat-milestone
```

特定のプロジェクトに新しい pull request を追加するには、`--project` フラグを使用します。

```shell
gh pr create --project octocat-project
```

個人またはチームをレビュー担当者として割り当てるには、`--reviewer` フラグを使用します。

```shell
gh pr create --reviewer monalisa,hubot --reviewer myorg/team-name
```

既定の Web ブラウザーで pull request を作成するには、`--web` フラグを使用します。

```shell
gh pr create --web
```

</div>

<div class="ghd-tool desktop">

1. **\[pull request をプレビューする]** をクリックします。
   GitHub Desktop は、現在のブランチとベース ブランチの間の変更の相違を示すプレビュー ダイアログを開きます。

   または、プル要求を作成する GitHub に直接移動するには、ドロップダウン アイコンを選択し、\[ **Pull Request の作成**] をクリックします。

2. **\[base:]** ドロップダウン メニューのブランチが、変更をマージするブランチであることを確認します。

   ![\[pull request を開く\] ダイアログ ウィンドウのスクリーンショット。 \[base: development\] というラベルが付いたドロップダウン アイコンが表示されているボタンがオレンジ色の枠線で囲まれています。](/assets/images/help/desktop/base-branch-selection.png)

GitHub Desktop は、現在のブランチをベース ブランチに自動的にマージできるかどうかを示します。

![\[pull request を開く\] ダイアログ ウィンドウのスクリーンショット。 \[自動的に結合できない\] という状態ラベルがオレンジ色の枠線で強調表示されています。](/assets/images/help/desktop/preview-dialog-merge-status.png)

1. **\[pull request の作成]** をクリックします。
   GitHub Desktop は既定のブラウザーを開き、 GitHubに移動します。
2. プルリクエストのタイトルと説明を入力します。
3. レビューの準備が完了している pull request を作成するには、 **\[pull request の作成]** をクリックします。
   ドラフトの pull request を作成するには、ドロップダウンを使用して、 **\[ドラフトの pull request の作成]** を選択し、 **\[ドラフトの pull request]** をクリックします。 組織のメンバーである場合は、組織の所有者から下書きプル要求へのアクセスを要求することが必要になることがあります。 「[Pull Request](/ja/enterprise-cloud@latest/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests#draft-pull-requests)」をご覧ください。

</div>

<div class="ghd-tool codespaces">

1. リポジトリのローカル コピーに変更をコミットしたら、\[ **プル要求の作成** ] アイコンをクリックします。

![\[ソース管理\] サイド バーの上部のスクリーンショット。 pull request アイコンが濃いオレンジ色の枠線で強調表示されています。](/assets/images/help/codespaces/codespaces-commit-pr-button.png)

1. マージ元のローカルブランチとリポジトリ、およびマージ先のリモートブランチとリポジトリが正しいことを確認します。 次に、pull request にタイトルと説明を付けます。

![\[GitHub pull request\] サイド バーと pull request を作成するフォームのスクリーンショット。\[タイトル\] と \[説明\] のフィールドが表示されています。](/assets/images/help/codespaces/codespaces-commit-pr.png)

1. **Create** をクリックしてください。

GitHub Codespacesでのプル要求の作成の詳細については、[pull request に GitHub Codespaces を使用する](/ja/enterprise-cloud@latest/codespaces/developing-in-a-codespace/using-github-codespaces-for-pull-requests) を参照してください。

</div>

## pull request 内のファイルに変更を加える

pull request を開いた後は、ヘッド ブランチに新しいコミットを追加することで、ファイルの変更を続行できます。

<div class="ghd-tool webui">

GitHub Web サイトでファイルを変更することもできます。

1. GitHubで、リポジトリ内のプル要求に移動します。
2. Pull request で、**\[<svg version="1.1" width="16" height="16" viewBox="0 0 16 16" class="octicon octicon-file-diff" aria-label="file-diff" role="img"><path d="M1 1.75C1 .784 1.784 0 2.75 0h7.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16H2.75A1.75 1.75 0 0 1 1 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h10.5a.25.25 0 0 0 .25-.25V4.664a.25.25 0 0 0-.073-.177l-2.914-2.914a.25.25 0 0 0-.177-.073ZM8 3.25a.75.75 0 0 1 .75.75v1.5h1.5a.75.75 0 0 1 0 1.5h-1.5v1.5a.75.75 0 0 1-1.5 0V7h-1.5a.75.75 0 0 1 0-1.5h1.5V4A.75.75 0 0 1 8 3.25Zm-3 8a.75.75 0 0 1 .75-.75h4.5a.75.75 0 0 1 0 1.5h-4.5a.75.75 0 0 1-.75-.75Z"></path></svg> Files changed]** をクリックします。

   ![pull request のタブのスクリーンショット。 \[変更されたファイル\] タブが濃いオレンジ色の枠線で囲まれています。](/assets/images/help/pull_requests/pull-request-tabs-changed-files.png)
3. 変更するファイルまで下にスクロールします。
   * pull request に多くのファイルがある場合は、フィルターを使用してファイルを見つけることができます。
4. 変更するファイルの上にある \[ <svg version="1.1" width="16" height="16" viewBox="0 0 16 16" class="octicon octicon-kebab-horizontal" aria-label="Show options" role="img"><path d="M8 9a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3ZM1.5 9a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Zm13 0a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z"></path></svg>] をクリックします。

![\[File changed\] タブのファイルの上にあるオプションのスクリーンショット。\[Show options\] ボタンがオレンジ色の四角形で強調されています。](/assets/images/help/pull_requests/menu-on-pull-request-file.png)

1. メニューで **\[Edit file]** をクリックします。
2. エディターで変更を加えます。 変更をコミットするときは、ヘッド ブランチに直接コミットすることを選択します。

</div>

## 詳細については、次を参照してください。

* [Creating a pull request from a fork](/ja/enterprise-cloud@latest/pull-requests/how-tos/create-pull-requests/creating-a-pull-request-from-a-fork)
* [ベースブランチとプルリクエストを同期させ続ける](/ja/enterprise-cloud@latest/pull-requests/how-tos/create-pull-requests/keeping-your-pull-request-in-sync-with-the-base-branch)
* [Changing the base branch of a pull request](/ja/enterprise-cloud@latest/pull-requests/how-tos/create-pull-requests/changing-the-base-branch-of-a-pull-request)
* [課題の作成](/ja/enterprise-cloud@latest/issues/tracking-your-work-with-issues/using-issues/creating-an-issue)
* [他のGitHub ユーザーに問題とプル要求を割り当てる](/ja/enterprise-cloud@latest/issues/tracking-your-work-with-issues/using-issues/assigning-issues-and-pull-requests-to-other-github-users)
* [GitHub での執筆](/ja/enterprise-cloud@latest/get-started/writing-on-github)