How do I embed a single file from a GitHub gist with the new gist interface?

Travis Reeder picture Travis Reeder · Jan 8, 2013 · Viewed 14.4k times · Source

The new GitHub Gist interface has one embed snippet for the entire gist which embeds all files in the gist. The old interface had embed code for each file in the gist. Anyone know if there's a trick to embed a single file?

Answer

Roland Kuhn picture Roland Kuhn · Jan 10, 2013

Take the gist URL from the left-hand side and after the .js add a query string like ?file=myFile.blah, e.g.

<script src="https://gist.github.com/4505639.js?file=macroBuild.scala" type="text/javascript"></script>