How do I get Copilot Chat to actually use multiple files as context? #203041
🏷️ Discussion TypeBug 💬 Feature/Topic AreaCopilot in GitHub BodyHey, quick one — I keep trying to get Copilot Chat to reference more than one file at a time when I'm asking it something, but it seems like it only really pays attention to whatever file I currently have open. I've tried using #file a couple times to point to other files in the repo, but the answers I get back still feel like they're only based on the active tab, not the other file I referenced. For anyone who's used this a lot: Do you have a reliable way to get it to pull in more than one file at once? Mostly just trying to figure out the right workflow so I'm not copy-pasting code into the chat manually every time. |
Replies: 2 comments
|
💬 Your Product Feedback Has Been Submitted 🎉 Thank you for taking the time to share your insights with us! Your feedback is invaluable as we build a better GitHub experience for all our users. Here's what you can expect moving forward ⏩
Where to look to see what's shipping 👀
What you can do in the meantime 💻
As a member of the GitHub community, your participation is essential. While we can't promise that every suggestion will be implemented, we want to emphasize that your feedback is instrumental in guiding our decisions and priorities. Thank you once again for your contribution to making GitHub even better! We're grateful for your ongoing support and collaboration in shaping the future of our platform. ⭐ |
|
Yeah, #file is the right idea, just a couple gotchas: #file:path/to/file.js works best when you give it the actual relative path, not just the filename, especially in bigger repos where names might clash. If it's still only responding based on the active tab even with #file in the prompt, worth double checking you're on a recent version, this behavior got more reliable in the last couple releases. |
Yeah, #file is the right idea, just a couple gotchas:
#file:path/to/file.js works best when you give it the actual relative path, not just the filename, especially in bigger repos where names might clash.
It doesn't need the file open in a tab, just referencing it with #file should pull it into context even if it's closed.
You can stack multiple #file refs in one message, so #file:utils.js #file:api.js explain how these interact actually does pull both in, it's not limited to one.
If it still feels like it's ignoring one of them, it's usually a length/context thing, really big files can get truncated so it prioritizes the most relevant chunks rather than the whole file.
#codebase is also …