Skip to main content
ドキュメントへの更新が頻繁に発行されており、このページの翻訳はまだ行われている場合があります。 最新の情報については、「英語のドキュメント」を参照してください。

Getting started with GitHub Copilot

You can start using GitHub Copilot by installing the extension in your preferred environment.

GitHub Copilot は、GitHub Copilot for Individuals の個人アカウントと GitHub Copilot for Business の Organization アカウントで利用できます。

確認が取れている学生、教師、およびパブリックのオープン ソース プロジェクトのメンテナンス担当者は、GitHub Copilot を無料で使うことができます。 学生、教師、または一般的なオープンソース プロジェクトのメンテナンス担当者ではない場合にも、1 回限りの 60 日間の試用版で GitHub Copilot を無料で試すことができます。 無料試用版の後、継続して使用するために有料サブスクリプションが必要になります。詳細については、「GitHub Copilot の課金について」を参照してください。

GitHub Copilot を試す

About GitHub Copilot and JetBrains IDEs

GitHub Copilot では、コーディング時に AI ペア プログラマーからオートコンプリート スタイルの候補が提示されます。 詳しくは、「GitHub Copilot for Individuals について」をご覧ください。

If you use a JetBrains IDE, you can view and incorporate suggestions from GitHub Copilot directly within the editor. This guide demonstrates how to use GitHub Copilot within a JetBrains IDE for macOS, Windows, or Linux.

Prerequisites

  • GitHub Copilot を使用するには、アクティブな GitHub Copilot サブスクリプションが必要です。 詳しくは、「GitHub Copilot の課金について」を参照してください。

  • To use GitHub Copilot in JetBrains, you must have a compatible JetBrains IDE installed. GitHub Copilot is compatible with the following IDEs:

    • IntelliJ IDEA (Ultimate, Community, Educational)
    • Android Studio
    • AppCode
    • CLion
    • Code With Me Guest
    • DataGrip
    • DataSpell
    • GoLand
    • JetBrains Client
    • MPS
    • PhpStorm
    • PyCharm (Professional, Community, Educational)
    • Rider
    • RubyMine
    • WebStorm

    For more information, see the JetBrains IDEs tool finder.

Installing the GitHub Copilot extension in your JetBrains IDE

To use GitHub Copilot in a JetBrains IDE, you must install the GitHub Copilot extension. The following procedure will guide you through installation of the GitHub Copilot plugin in IntelliJ IDEA. Steps to install the plugin in another supported IDE may differ.

  1. In your JetBrains IDE, under the File menu for Windows or under the name of your IDE for Mac (for example, PyCharm or IntelliJ), click Settings for Windows or Preferences for Mac.

  2. In the left-side menu of the Settings/Preferences dialog box, click Plugins.

  3. At the top of the Settings/Preferences dialog box, click Marketplace. In the search bar, search for GitHub Copilot, then click Install.

    Screenshot of Marketplace search

  4. After GitHub Copilot is installed, click Restart IDE.

  5. After your JetBrains IDE has restarted, click the Tools menu. Click GitHub Copilot, then click Login to GitHub.

    Screenshot of JetBrains tools menu.

  6. In the "Sign in to GitHub" dialog box, to copy the device code and open the device activation window, click Copy and Open.

    Screenshot of device code copy and open

  7. A device activation window will open in your browser. Paste the device code, then click Continue.

  8. GitHub will request the necessary permissions for GitHub Copilot. To approve these permissions, click Authorize GitHub Copilot Plugin.

  9. After the permissions have been approved, your JetBrains IDE will show a confirmation. To begin using GitHub Copilot, click OK.

Seeing your first suggestion

注: GitHub Copilot の重複検出を有効にしている場合、用意されているコード例を使うと、受け取る提案数が少ない場合、または提案がまったくない場合があります。 または、自作のコードを入力して GitHub Copilot からの提案を確認することから始めることもできます。 重複検出の詳細については、「GitHub.com での GitHub Copilot 設定の構成」を参照してください。

GitHub Copilot は、多数の言語とさまざまなフレームワークに対する候補を提示しますが、特に Python、JavaScript、TypeScript、Ruby、Go、C#、C++ に適しています。 The following samples are in Java, but other languages will work similarly.

  1. JetBrains IDE で、新しい Java ( *.java) のファイルを作成します。
  2. In the Java file, create a class by typing class Test. GitHub Copilot will automatically suggest a class body in grayed text. The exact suggestion may vary.
  3. 候補を受け入れるには、Tab キーを押します。
  4. To prompt GitHub Copilot to suggest a function body, type the following line below the bracket of the main function. The exact suggestion may vary.
    Java
    int calculateDaysBetweenDates(
  5. 候補を受け入れるには、Tab キーを押します。

GitHub Copilot will attempt to match the context and style of your code. You can always edit the suggested code.

Seeing alternative suggestions

特定の入力に対して、GitHub Copilot が複数の候補を提示することがあります。 使う候補を選択するか、すべての候補を拒否できます。

  1. JetBrains IDE で、新しい Java ( *.java) のファイルを作成します。

  2. To prompt GitHub Copilot to show you a suggestion, type the following line in the Java file.

    Java
    int calculateDaysBetweenDates(
  3. 必要に応じて、使用可能な場合は、代替候補を表示できます。

    OSSee next suggestionSee previous suggestion
    macOSOption+]Option+[
    WindowsAlt+]Alt+[
    LinuxAlt+]Alt+[
  4. 候補を受け入れるには、Tab キーを押します。すべての候補を拒否するには、Esc キーを押します。

Seeing multiple suggestions in a new tab

GitHub Copilot が提示する最初の候補はどれも必要ないかもしれません。 キーボード ショートカットを使って、GitHub Copilot で新しいタブに複数の候補を表示するように指示できます。

  1. JetBrains IDE で、新しい Java ( *.java) のファイルを作成します。

  2. To prompt GitHub Copilot to show you a suggestion, type the following line in the Java file.

    Java
    int calculateDaysBetweenDates(
  3. Open a new tab with multiple additional suggestions.

    • On macOS, press Command+Shift+A, then click Open GitHub Copilot, or press Command+Shift+\ to open the new tab immediately.
    • On Windows or Linux, press Ctrl+Enter, then click Open GitHub Copilot.
  4. To accept a suggestion, above the suggestion, click Accept Solution. To reject all suggestions, close the tab.

Generating code suggestions from comments

コメント内で自然言語を使用して実行する操作を記述できます。GitHub Copilot では、目標を達成するためのコードの候補が示されます。

  1. JetBrains IDE で、新しい Java ( *.java) のファイルを作成します。
  2. To prompt GitHub Copilot to suggest an implementation of a function in the Java file, type the following lines.
    Java
    // find all images without alternate text
    // and give them a red border
    void process () {

Enabling and disabling GitHub Copilot

You can enable or disable GitHub Copilot for all languages, or for individual languages. The GitHub Copilot status icon in the bottom panel of your JetBrains IDE window indicates whether GitHub Copilot is enabled or disabled. When enabled, the icon is highlighted. When disabled, the icon is grayed out.

  1. To enable or disable GitHub Copilot, click the status icon in the bottom panel of the JetBrains window.

    Screenshot of the status icon in IntelliJ IDEA

  2. If you are disabling GitHub Copilot, you will be asked whether you want to disable it globally, or for the language of the file you are currently editing.

    • To disable suggestions from GitHub Copilot globally, click Disable Completions.
    • To disable suggestions from GitHub Copilot for the specified language, click Disable Completions for LANGUAGE.

    Screenshot of option to disable GitHub Copilot globally or for the current language

Further reading

About GitHub Copilot and Visual Studio

GitHub Copilot では、コーディング時に AI ペア プログラマーからオートコンプリート スタイルの候補が提示されます。 詳しくは、「GitHub Copilot for Individuals について」をご覧ください。

If you use Visual Studio, you can view and incorporate suggestions from GitHub Copilot directly within the editor. This guide demonstrates how to use GitHub Copilot within Visual Studio for Windows.

Prerequisites

  • GitHub Copilot を使用するには、アクティブな GitHub Copilot サブスクリプションが必要です。 詳しくは、「GitHub Copilot の課金について」を参照してください。

  • To use GitHub Copilot in Visual Studio, you must have Visual Studio 2022 17.4.4 or later installed. For more information, see the Visual Studio IDE documentation.

Note: GitHub Copilot is not currently available for use with Visual Studio for Mac.

Installing the Visual Studio extension

To use GitHub Copilot, you must first install the Visual Studio extension.

  1. In the Visual Studio toolbar, click Extensions, then click Manage Extensions.

    Screenshot of the Visual Studio toolbar

  2. In the "Manage Extensions" window, click Visual Studio Marketplace, search for the GitHub Copilot extension, then click Download.

    Screenshot of GitHub Copilot extension for Visual Studio with the download button emphasized

  3. Close the "Manage Extensions" window, then exit and relaunch Visual Studio.

  4. Optionally, to check that GitHub Copilot is installed and enabled, go back to Manage Extensions, click Installed to view your currently installed extensions, then click GitHub Copilot to see status information.

    Screenshot of installed extensions in Visual Studio with GitHub Copilot emphasized

  5. Open or create a new project in Visual Studio.

  6. In the "Microsoft Visual Studio" dialog box, to copy your device activation code, click OK.

  7. A device activation window will open in your browser. Paste the device code, then click Continue.

  8. GitHub will request the necessary permissions for GitHub Copilot. To approve these permissions, click Authorize GitHub Copilot Plugin.

  9. After you approve the permissions, Visual Studio will show a confirmation.

Seeing your first suggestion

注: GitHub Copilot の重複検出を有効にしている場合、用意されているコード例を使うと、受け取る提案数が少ない場合、または提案がまったくない場合があります。 または、自作のコードを入力して GitHub Copilot からの提案を確認することから始めることもできます。 重複検出の詳細については、「GitHub.com での GitHub Copilot 設定の構成」を参照してください。

GitHub Copilot は、多数の言語とさまざまなフレームワークに対する候補を提示しますが、特に Python、JavaScript、TypeScript、Ruby、Go、C#、C++ に適しています。 The following samples are in C#, but other languages will work similarly.
  1. Visual Studio で、新しい C# ( *.cs) ファイルを作成します。

  2. In the C# file, type the following function signature. GitHub Copilot will automatically suggest an entire function body in grayed text, as shown below. The exact suggestion may vary.

    C#
    int CalculateDaysBetweenDates(
  3. 候補を受け入れるには、Tab キーを押します。

Seeing alternative suggestions

特定の入力に対して、GitHub Copilot が複数の候補を提示することがあります。 使う候補を選択するか、すべての候補を拒否できます。

  1. Visual Studio で、新しい C# ( *.cs) ファイルを作成します。

  2. In the C# file, type the following function signature. GitHub Copilot will show you a suggestion.

    C#
    int CalculateDaysBetweenDates(
  3. If alternative suggestions are available, you can see these alternatives by pressing Alt+] (or Alt+[).

  4. Optionally, you can hover over the suggestion to see the GitHub Copilot command palette for choosing suggestions.

  5. 候補を受け入れるには、Tab キーを押します。すべての候補を拒否するには、Esc キーを押します。

Generating code suggestions from comments

コメント内で自然言語を使用して実行する操作を記述できます。GitHub Copilot では、目標を達成するためのコードの候補が示されます。

  1. Visual Studio で、新しい C# ( *.cs) ファイルを作成します。

  2. In the C# file, type the following comment. GitHub Copilot will suggest an implementation of the function.

    C#
    using System.Xml.Linq;
    
    var doc = XDocument.Load("index.xhml");
    
    // find all images
  3. 候補を受け入れるには、Tab キーを押します。

GitHub Copilot の有効化または無効化

Visual Studio ウィンドウの下部パネルにある GitHub Copilot 状態アイコンは、GitHub Copilot が有効であるか無効であるかを示します。 有効にすると、アイコンの背景色はステータス バーの色と一致します。 無効にすると、異なるものになります。

  1. GitHub Copilot を有効または無効にするには、Visual Studio ウィンドウの下部パネルにある GitHub Copilot アイコンをクリックします。

    GitHub Copilot アイコンが強調された Visual Studio のエディターの端のスクリーンショット

  2. GitHub Copilot を無効にする場合は、候補をグローバルに無効にするか、現在編集中のファイルの言語に対して無効にするかを確認するメッセージが表示されます。

    • GitHub Copilot からの候補をグローバルに無効にするには、 [グローバルに有効にする] をクリックします。
    • 指定された言語に対して GitHub Copilot からの候補を無効にするには、 [言語に対して有効にする] をクリックします。

Further reading

About GitHub Copilot and Visual Studio Code

GitHub Copilot では、コーディング時に AI ペア プログラマーからオートコンプリート スタイルの候補が提示されます。 詳しくは、「GitHub Copilot for Individuals について」をご覧ください。

If you use Visual Studio Code, you can view and incorporate suggestions from GitHub Copilot directly within the editor. This guide demonstrates how to use GitHub Copilot within Visual Studio Code for macOS, Windows, or Linux.

Prerequisites

  • GitHub Copilot を使用するには、アクティブな GitHub Copilot サブスクリプションが必要です。 詳しくは、「GitHub Copilot の課金について」を参照してください。

  • To use GitHub Copilot in Visual Studio Code, you must have Visual Studio Code installed. For more information, see the Visual Studio Code download page.

Installing the Visual Studio Code extension

To use GitHub Copilot, you must first install the Visual Studio Code extension.

  1. In the Visual Studio Code Marketplace, go to the GitHub Copilot extension page and click Install.

  2. A popup will appear, asking to open Visual Studio Code. Click Open Visual Studio Code.

  3. In the "Extension: GitHub Copilot" tab in Visual Studio Code, click Install.

  4. If you have not previously authorized Visual Studio Code in your GitHub account, you will be prompted to sign in to GitHub in Visual Studio Code.

    • If you have previously authorized Visual Studio Code for your account on GitHub, GitHub Copilot will be automatically authorized.
  5. In your browser, GitHub will request the necessary permissions for GitHub Copilot. To approve these permissions, click Authorize Visual Studio Code.

  6. To confirm the authentication, in Visual Studio Code, in the "Visual Studio Code" dialog box, click Open.

Seeing your first suggestion

注: GitHub Copilot の重複検出を有効にしている場合、用意されているコード例を使うと、受け取る提案数が少ない場合、または提案がまったくない場合があります。 または、自作のコードを入力して GitHub Copilot からの提案を確認することから始めることもできます。 重複検出の詳細については、「GitHub.com での GitHub Copilot 設定の構成」を参照してください。

GitHub Copilot は、多数の言語とさまざまなフレームワークに対する候補を提示しますが、特に Python、JavaScript、TypeScript、Ruby、Go、C#、C++ に適しています。 The following samples are in JavaScript, but other languages will work similarly.

  1. Visual Studio Code で、新しい JavaScript ( *.js) のファイルを作成します。

  2. In the JavaScript file, type the following function header. GitHub Copilot will automatically suggest an entire function body in grayed text, as shown below. The exact suggestion may vary.

    JavaScript
    function calculateDaysBetweenDates(begin, end) {
  3. 候補を受け入れるには、Tab キーを押します。

Seeing alternative suggestions

特定の入力に対して、GitHub Copilot が複数の候補を提示することがあります。 使う候補を選択するか、すべての候補を拒否できます。

  1. Visual Studio Code で、新しい JavaScript ( *.js) のファイルを作成します。

  2. In the JavaScript file, type the following function header. GitHub Copilot will show you a suggestion.

    JavaScript
    function calculateDaysBetweenDates(begin, end) {
  3. 必要に応じて、使用可能な場合は、代替候補を表示できます。

    OSSee next suggestionSee previous suggestion
    macOSOption (⌥) or Alt+]Option (⌥) or Alt+[
    WindowsAlt+]Alt+[
    LinuxAlt+]Alt+[
  4. Alternatively, you can hover over the suggestion to see the GitHub Copilot command palette for choosing suggestions.

  5. 候補を受け入れるには、Tab キーを押します。すべての候補を拒否するには、Esc キーを押します。

Seeing multiple suggestions in a new tab

GitHub Copilot が提示する最初の候補はどれも必要ないかもしれません。 キーボード ショートカットを使って、GitHub Copilot で新しいタブに複数の候補を表示するように指示できます。

  1. Visual Studio Code で、新しい JavaScript ( *.js) のファイルを作成します。
  2. In the JavaScript file, type the following function header. GitHub Copilot will show you a suggestion.
    JavaScript
    function calculateDaysBetweenDates(begin, end) {
  3. To open a new tab with multiple additional options, press Ctrl+Enter.
  4. To accept a suggestion, above the suggestion, click Accept Solution. To reject all suggestions, close the tab.

Generating code suggestions from comments

コメント内で自然言語を使用して実行する操作を記述できます。GitHub Copilot では、目標を達成するためのコードの候補が示されます。

  1. Visual Studio Code で、新しい JavaScript ( *.js) のファイルを作成します。
  2. In the JavaScript file, type the following comment. GitHub Copilot will suggest an implementation of the function.
    JavaScript
    // find all images without alternate text
    // and give them a red border
    function process() {

Using a framework

You can also use GitHub Copilot to generate suggestions for APIs and frameworks. The following example uses GitHub Copilot to create a simple Express server that returns the current time.

  1. Visual Studio Code で、新しい JavaScript ( *.js) のファイルを作成します。
  2. In the JavaScript file, type the following comment and then press Enter. GitHub Copilot will suggest an implementation of the Express app.
    JavaScript
    // Express server on port 3000
  3. To accept each line, press Tab, then Enter.
  4. Type the following comment and then press Enter. GitHub Copilot will suggest an implementation for the default handler.
    JavaScript
    // Return the current time
  5. To accept each line, press Tab.

GitHub Copilot の有効化または無効化

Visual Studio Code 内から GitHub Copilot を有効または無効にすることができます。 Visual Studio Code ウィンドウの下部パネルにある GitHub Copilot 状態アイコンは、GitHub Copilot が有効であるか無効であるかを示します。 有効にすると、アイコンの背景色はステータス バーの色と一致します。 無効にすると、アイコンの背景色はステータス バーの色と異なります。

  1. GitHub Copilot を有効または無効にするには、Visual Studio Code ウィンドウの下部パネルにある状態アイコンをクリックします。

    Visual Studio Code の下部パネルのスクリーンショット。 GitHub Copilot アイコンが濃いオレンジ色の枠線で囲まれています。

  2. GitHub Copilot を無効にする場合は、候補をグローバルに無効にするか、現在編集中のファイルの言語に対して無効にするかを確認するメッセージが表示されます。

    • GitHub Copilot からの候補をグローバルに無効にするには、 [グローバルに無効にする] をクリックします。
    • 指定された言語に対して GitHub Copilot からの候補を無効にするには、 [言語に対して無効にする] をクリックします。 GitHub Copilot をグローバルに、または現在の言語に対して無効にするためのオプションのスクリーンショット

Further reading

About GitHub Copilot and Neovim

GitHub Copilot では、コーディング時に AI ペア プログラマーからオートコンプリート スタイルの候補が提示されます。 詳しくは、「GitHub Copilot for Individuals について」をご覧ください。

If you use Neovim, you can view and incorporate suggestions from GitHub Copilot directly within the editor.

Prerequisites

  • GitHub Copilot を使用するには、アクティブな GitHub Copilot サブスクリプションが必要です。 詳しくは、「GitHub Copilot の課金について」を参照してください。

  • To use GitHub Copilot in Neovim you must have Neovim version 0.6 or above and Node.js version 17 or below installed. For more information, see the Neovim documentation and the Node.js website.

Installing the Neovim extension on macOS

  1. GitHub は、Neovim の組み込みプラグイン マネージャーを使って GitHub Copilot プラグインをインストールすることをお勧めします。 または、任意のプラグイン マネージャーを使って github/copilot.vim をインストールすることもできます。

  2. GitHub は、Neovim の組み込みプラグイン マネージャーを使って GitHub Copilot プラグインをインストールすることをお勧めします。 または、任意のプラグイン マネージャーを使って github/copilot.vim をインストールすることもできます。

    • To install GitHub Copilot with Neovim's built-in plugin manager, enter the following command in Terminal:

      git clone https://github.com/github/copilot.vim \
         ~/.config/nvim/pack/github/start/copilot.vim
      
  3. GitHub Copilot を構成するには、Neovim を開き、次のコマンドを入力します。

    :Copilot setup
    
  4. Neovim の構成で、または Neovim コマンドを使って GitHub Copilot を有効にします。

    :Copilot enable
    

Installing the Neovim extension on Windows

  1. GitHub は、Neovim の組み込みプラグイン マネージャーを使って GitHub Copilot プラグインをインストールすることをお勧めします。 または、任意のプラグイン マネージャーを使って github/copilot.vim をインストールすることもできます。

    • To install GitHub Copilot with Neovim's built-in plugin manager, enter the following command in Git Bash:

        git clone https://github.com/github/copilot.vim.git \
         $HOME/AppData/Local/nvim/pack/github/start/copilot.vim
      
  2. GitHub Copilot を構成するには、Neovim を開き、次のコマンドを入力します。

    :Copilot setup
    
  3. Neovim の構成で、または Neovim コマンドを使って GitHub Copilot を有効にします。

    :Copilot enable
    

Installing the Neovim extension on Linux

  1. GitHub は、Neovim の組み込みプラグイン マネージャーを使って GitHub Copilot プラグインをインストールすることをお勧めします。 または、任意のプラグイン マネージャーを使って github/copilot.vim をインストールすることもできます。

    • To install GitHub Copilot with Neovim's built-in plugin manager, enter the following command:

      git clone https://github.com/github/copilot.vim \
         ~/.config/nvim/pack/github/start/copilot.vim
      
  2. GitHub Copilot を構成するには、Neovim を開き、次のコマンドを入力します。

    :Copilot setup
    
  3. Neovim の構成で、または Neovim コマンドを使って GitHub Copilot を有効にします。

    :Copilot enable
    

Learning to use GitHub Copilot in Neovim

For guidance on using GitHub Copilot in Neovim, you can view the plugin documentation. To see the documentation, open Neovim and run the following command:

:help copilot

Further reading