DEV Community

Cassidy Williams
Cassidy Williams

Posted on • Originally published at cassidoo.co on

Have GitHub Copilot see your diff (and other cool tricks)

I learned today that you can have GitHub Copilot pay attention specifically to the current changes in your repository!

I had been working on a branch for a few days on a project, and realized I broke something along the way. I had been working just long enough that scouring the git diff would probably take a while, but I also wanted to parse a bit more about what I had specifically done in certain files.

And thus, I learned about #changes! When you use GitHub Copilot (specifically the chat mode, I personally use VS Code), you can use #changes as a variable in your message to list out your current changes before you commit.

So, for example you can say:

Summarize all of my #changes so far

or, how I used it…

I broke the Feed component. Which files touch the component currently in #changes?

Kinda nice! If you want to check out the docs, there’s a bunch of variables you can use too, like:

  • #usages as a combination of “Find All References”, “Find Implementation”, and “Go to Definition”
  • #selection for the current editor selection as context
  • #searchResults for the results from your latest search as context
  • #fetch to get the content of a web page

(and mooooore)

Hope this was helpful!

Top comments (1)

Collapse
 
erik_vandeven_ec838b7c4 profile image
Erik van de Ven • Edited

For the folks who want to use #changes to analyze an open PR (so for stuff that is actually already committed):

  1. checkout the branch locally
  2. create a new branch based on that branch (just to be safe)
  3. use git reset --soft $(git merge-base HEAD origin/main)

Then all the changes are staged and available for the #changes command again.