Highlight specific lines in a Github repo file

Heres a quick and easy tip to highlight selected lines in a GitHub repo file when you link to it.

Lets say you want to link to a specific file in a GitHub repo but its a huge file and you specifically want someone to see a certain section. You could always just say “hey check out lines 25-30” but thats annoying. Instead you can include querystring parameters in the URL that will highlight a block of lines that you want:

Original url:

https://github.com/jkat98/benm/blob/master/server.js

Same url with lines 18 thru 24 highlighted:

https://github.com/jkat98/benm/blob/master/server.js#L18-L24

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s