Lucas da Costa Profile picture
Jun 14, 2022 18 tweets 6 min read Read on X
These GitHub shortcuts have saved hours of manual work and poking around interfaces to find the information I need.

Furthermore, they help me write better issues and pull requests, with more info, in less time.

GitHub tips and tricks, a thread 🧵
⭐ Finding files

Pressing "t" within a repository will open a file finder that filters files as you type.

This file-finder is a "fuzzy finder, " meaning you don't necessarily have to know the exact name of the file you want to find.
⭐ Displaying keyboard keys

Wrapping text into <kbd> tags will display text as "keys" in issues, pull-requests, and markdown files within GitHub.

To tell someone they should press the key A, for example, you could write <kbd>A</kbd>.
⭐ Displaying colors for hex codes

Wrapping hex codes into backticks (`) will cause a box with the code's color to be rendered right next to its code.

To render the color red, for example, you could use `#FF0000`.
⭐ Linking to a range of lines

To create a link to a particular range of lines, you can click on the line number at the beginning of the range and then hold shift while clicking the last line in the range.
Doing that will cause GitHub to append the line range to the URL in your address bar.

If you've selected lines 10 to 20, for example, your URL will end with #L10-L20.

As I'll show next, generating URLs for line ranges is helpful for including snippets into issues and PRs.
⭐ Generating perma-links to a file at a particular point in time

If you go to a repo's file and copy the link on your address bar, it will look something like:

github.com/user/repo/blob…
The problem with this link is that file.md might be deleted or renamed.

If that happens, your link will end up pointing to nowhere!

➡️ To get a permanent link to https://t.co/oBfShT4PGw at the current time, press "y"!
Pressing "y" will change the URL in your address bar to include the commit's hash (its unique identifier).

Now, your link should look like this:

github.com/user/repo/blob/<SHA>/file.md

This link will *always* point to file.md at that point in time.
Using "y" to include the commit's SHA in a URL also helps you have stable references to a particular range of lines.

Imagine you have sent a colleague a link to a file's first 10 lines, for example.
If those 10 lines change before your colleague clicks the link, the 10 lines they will see will be different from the 10 lines you've seen when you sent them the link.

Pressing "y" before copying a URL solves that problem.
⭐ Including native code snippets in issues and PRs

To include GitHub code snippets into issues and PRs, select a range of lines, press "y" to obtain a perma-link, and paste that perma-link into your issue/PR.

GitHub will render that link within a code-snippet box. Image
⭐ Toggling comments on and off on pull-requests

When pull requests get too busy, I often find it hard to read the code with all those commends in the middle of it.

Pressing "i" toggles comments on and off so you can focus on what matters.
⭐ Viewing who changed what (blame) within GitHub

Pressing "b" while viewing a file will show you who changed which lines (git blame).

You can use this feature to easily find the PR in which changes were introduced and, therefore, obtain more context about an issue.
To find which PR introduced a change, start by pressing "b" on the page for the file which contains the changes.

Then, click the commit that modified the desired line range.

Finally, click the PR link on the left of the summary message, as shown in the gif above.
⭐ Collapsable long pieces of information

Whenever you have long pieces of information, such as log samples or stack traces, consider using a collapsable box to allow readers to show and hide information as they wish.
To create a collapsable box like the one above, you'll have to use the <details> tag to wrap all of your content.

Within <details>, add a callout for the box using the <summary> tag.

Finally, paste the content for the box within a <pre> tag.
That's a wrap!

If you liked this thread:

1. Follow me @thewizardlucas for more of these
2. RT the tweet below to share this thread 👇

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Lucas da Costa

Lucas da Costa Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @thewizardlucas

Apr 18, 2023
You probably already know all about Vim's basics, so I'll skip that.

Here are 20 Vim tips you haven't heard before 🧵
1. Use marks to navigate: You can set marks in Vim using the "m" key followed by a letter. For example, "ma" sets a mark at the current cursor position with the name "a", and "'a" will jump the cursor to that mark.
2. Use registers for copy-pasting: Vim has a number of registers that can be used to copy and paste text. Use "d" to delete text and "y" to yank (copy) text. To paste from a register, use "p" followed by the register name, such as "0p" to paste from register 0.
Read 21 tweets
Apr 17, 2023
Most people have seen CORS errors before, but most have no idea what CORS is and why it exists.

Here's everything you absolutely must know about CORS if you're a web developer 🧵 Image
CORS, or Cross-Origin Resource Sharing, is a security mechanism implemented in web browsers that allow or restricts web pages to request resources from a different domain than the one they were served from. Image
CORS helps protect users' data and prevent malicious websites from making unauthorized requests to another website on the user's behalf.
Read 25 tweets
Nov 11, 2022
My first impressions of Brazil (São Paulo) 🇧🇷 after having lived in London 🇬🇧 for 5 years 🧵
1. Friendliness

I missed this so much.

In England, everyone is polite and helpful, but interactions don’t tend to get personal.

In Brazil people genuinely smile, laugh, and want to keep a conversation.
Here, people treat you personally, and act as if they were your friends already.

You may think that doesn’t happen as much in São Paulo because it’s a huge city, and it may be true compared to other places in Brazil.

Still, the difference when compared to Europe is shocking.
Read 15 tweets
Sep 30, 2022
How I got into programming.

A thread about how I learned to code by operating a fantasy multi-millionaire enterprise in an online RPG 🧵
I got into programming at the age of 14.

At that time, my friends and I used to play an online MMORPG called Ragnarok Online, which was extremely popular in Brazil.

Although Ragnarok Online was fun, it required a significant amount of commitment.
If you wanted your character to be competitive against other players and monsters, you'd have to spend quite a few months collecting, trading, and selling items so that you could buy powerful swords, shields, and pieces of armor.
Read 39 tweets
Sep 28, 2022
Why does package-lock.json exist, and how does it work?

A thread 🧵
When writing JavaScript applications, you describe their dependencies using a package.json file.

This file contains all of your application's direct dependencies and their versions.
If you’re building a RESTful API using Express, for, example, your package.json file will probably list express as a dependency. Image
Read 47 tweets
Aug 22, 2022
Welcome to Bike Shed Co.

Please come in.

Here, we know it feels terrible when results get in the way of following processes.

Instead of building products and talking to customers, we spend time on the things that truly matter: Gantt charts, slide decks, and word documents.

🧵
We deeply believe that the only way to fail is to actually try.

If you never ship something, no one will ever tell you that the product sucks. Therefore, we can’t fail.
Unfortunately, sometimes, you will have to ship something.

In any case, you shouldn’t allow that pointless task to affect your morale.

Shipping is part of the theatre necessary to demonstrate we deserve more capital.
Read 40 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(