GH-300 practice question 4 of 10

How can you improve the context used by GitHub Copilot? (Each correct answer presents part of the solution. Choose two.)

Full set: 135 questions
Answer options
A: By opening the relevant tabs in your IDE Correct answer
B: By adding relevant code snippets to your prompt Correct answer
C: By adding the important files to your .gitconfig
D: By adding the full file paths to your prompt of important files
Correct Answer:
A. By opening the relevant tabs in your IDE; B. By adding relevant code snippets to your prompt
Explanation

GitHub Copilot's effectiveness is highly dependent on the quality and relevance of the context it receives. The primary sources of context are the files currently open in the Integrated Development Environment (IDE). By opening files relevant to your current task, you provide Copilot with a broader understanding of the project's architecture, existing functions, and coding conventions. Additionally, when interacting with Copilot Chat or using inline prompts, providing specific code snippets directly within the prompt gives Copilot precise, immediate context to generate a targeted and accurate response, such as refactoring a function or explaining a block of code.

Why Incorrect

C. The .gitconfig file is used for configuring the Git version control system and has no influence on the context used by GitHub Copilot.
D. Simply adding file paths to a prompt is not the standard or most effective method; Copilot gains context by analyzing the actual content of open files.

References

1. Official GitHub Documentation

"Getting started with GitHub Copilot": This document explains the core functionality of Copilot. It states

"As you type

it analyzes the context from your comments and code

and offers suggestions from within your editor... GitHub Copilot processes context from the file you are editing

and related files..." This directly supports that open files (tabs) are a key source of context.

Source: GitHub Docs

"Getting started with GitHub Copilot

" section on "About GitHub Copilot."

2. Official GitHub Documentation

"Using GitHub Copilot Chat in your IDE": This guide details how to interact with Copilot Chat. It emphasizes providing specific context in prompts: "You can ask Copilot Chat to help with a specific piece of code. To do this

highlight the code in your editor and then ask your question." This action is equivalent to adding a relevant code snippet to the prompt's context.

Source: GitHub Docs

"Using GitHub Copilot Chat in your IDE

" section on "Asking questions about your code."

Scroll to Top