GitHub provides this same information here on their site. As others have said the official way is to attach ?file=name-of-file.ext to the end of the embed code's URL in order to only embed the file called name-of-file.ext (you can of course change the name to whatever the name of your file is). For example, if I wanted to embed the getGitContents.js file from the Gist at https://gist.github.com/westc/afac9258389fdfd2fdaf134ffaa0e923 I can use the following:
In addition there is this YourJS blog post about this which allows you to enter your user name and see the embed codes for all of your gists and the underlying individual files.
For those who want to use it on the medium, Medium does not support and does not query parameters in the URL when you add it after the paste of the URL. So just follow these 4 steps IN THE ORDER.
⚠️ Note that you MUST copy an unformatted plain text in the medium and MUST NOT edit the URL after pasting it in the Medium! You can copy the link in an online textbox like google.com and after appending the query, copy it back and paste it in the Medium.