loading...
Cover image for 8 Productivity Tips for GitHub

8 Productivity Tips for GitHub

_darrenburns profile image Darren Burns Updated on ・4 min read

With the recent announcement of unlimited private repositories, let's take a few minutes before we push up the code we don’t want anyone else to see, and make sure we’re making the most of what GitHub has to offer.

GitHub is built with some extremely helpful shortcuts and productivity-boosting features. From personal experience, however, it’s clear that these often fall under the radar amongst developers. If I’ve ever witnessed a specific GitHub feature surprise or assist someone, then that feature is on this page. That said, what follows is by no means an exhaustive list.

Quick fuzzy file search in repositories

This is, without doubt, the fastest way to browse a repository when you know what you’re looking for. Open up any repository and press t. You can now search for the name of any file in the repository, and use the arrow keys on your keyboard to move through the results. Press Enter to open the file.

github-fuzzy-search

Code change suggestions in pull requests

When commenting on a piece of code in a pull request, you can suggest alternative code using the “Suggested Changes” feature. The author of the pull request will be able to apply your suggestion instantly without leaving GitHub.

To make the suggestion, surround a code snippet with a multiline Markdown snippet, with the tag suggestion:

gh-make-suggestion

Now that you’ve made the suggestion, the author of the pull request can immediately apply it to their branch, without the hassle of manually changing the file!

gh-apply-suggestion

Navigate the code tree like in an IDE

This one requires an unofficial Chrome extension, but it’s a slightly more familiar way to navigate your code compared to the default interface. The Octotree extension lets you browse GitHub repositories with a sidebar tree view similar to what you get in applications like VS Code.

octotree

Jump to a function when reviewing code

Unless you’re reviewing a single function, a code review often involves a lot of jumping between function calls and their definitions (and therefore a lot of scrolling up and down). GitHub lets you jump to a symbol by pressing t when you’re looking at files in a pull request.

gh-jump-to-symbol

Creating a permalink to a file

When viewing a file or directory, press y, and the URL will be converted to a permalink, which you can share knowing that the contents of the file will never change.

If you send a link to a file or directory on GitHub without making it into a permalink, you’ll need to accept the possibility that the file could disappear tomorrow, breaking the link!

Viewing the blame and change recency heatmap

When viewing a file, you can press b to view the Git blame and a heatmap showing how recently each line was changed. It’ll tell you who most recently changed each line of code, and give you a clickable link taking you to the full commit the change was part of.

On the right-hand side of the gutter (which contains the commit message and author), you’ll notice an orange vertical bar. The more vivid this bar is, the more recent the change, meaning you can easily scan the file to find the freshest code!

gh-blame

Powerful code search

GitHub indexes most code and offers powerful search functionality over it. If you need to find something in a repository, but don’t plan on making any changes to it. There’s usually no need to check the repository out. Press / to search all the code in the repository.

gh-code-search

If your search contains multiple words and you want to search for occurrences of your specific search query, put the quotations around the query. You can filter your searches by other things too, such as file size, extension, the path the file is on, and much more.

Saved replies

If you ever find yourself repeating the same comments, you’ll save some time by creating a saved reply. The next time you find you’re going to type that comment again, you can instead just select it from a drop-down menu:

gh-saved-replies

To perform the above action without using my mouse, I can do ctrl + . followed by ctrl + 1.

Conclusion

Thanks for reading. I hope you found at least one thing on this page that will make you a more productive GitHub user. If you enjoyed this post or have any feedback in general, let me know!

If you’re interested in more content like this, follow my Twitter.

Originally published on my blog.

P.S. You can make your own Octocat for sharing like the one in the cover photo at myoctocat.com!

Discussion

pic
Editor guide
Collapse
sarthology profile image
Sarthak Sharma

Great post Darren 👏🏻👏🏻

——————

Food for thought

For building such powerful and fast search system Github must be indexing our code. Is that ohk? 🤔
It’s make me uncomfortable as these features work on private repos as well.
I always use to wonder why Microsoft bought Github. What you guys think?

Collapse
rhymes profile image
rhymes

Hi Sarthak! You might want to take a look at GitHub's terms of service, specifically the section about private repos.

If you're not OK at GitHub potentially having access to your code under the terms then you should probably consider a self hosted solution.

It really depends on what you're comfortable with.

Collapse
sarthology profile image
Sarthak Sharma

Point is awareness. You know this, I know this but most developers out there, they are clueless.

Thread Thread
rhymes profile image
rhymes

Don't know, I think you underestimate developers or overestimate how much companies care about this a little bit.

Most cloud providers support teams can see your code if you authorize them to when you open a ticket and most terms include authorization to access your code, even if only for backups or redundancy.

With severless computing I'm even authorizing you provider to take my code, put it god knows where so you can start it up to serve customers.

BTW the argument could be made with data (which in a lot of cases is far more important than the code).

Thread Thread
sarthology profile image
Sarthak Sharma

Agreed, Data is more important but that also being stoled by these big crops. The only thing I'm concerned about is Microsoft. Github can be a great resource for them to build DeepCoder . Let's hope I'm wrong about this. 😃

Thread Thread
rhymes profile image
rhymes

Github can be a great resource for them to build DeepCoder.

Is it stolen though? GH has had a API for years. All the article says is that they used existing software code (which you can find everywhere thanks to open source) to feed the AI.

I understand your distrust but if you believe your data is being actively stolen by a cloud provider (not talking about privacy related data leaks of companies in general) I think you can likely sue them.

It would be a giant blowback if the database of a customer is being stolen for internal usage against the terms of service. Imagine the PR nightmare and I reckon many people would migrate instantly.

I think it's far easier and less risky for cloud providers to just copy your idea and offer it as a standard service, like AWS seems to be doing from time to time :D

Thread Thread
sarthology profile image
Sarthak Sharma

It's okay. I respect your way of thinking too. The thing is that other people should be thinking more about their privacy than they do and if they that's good. Often free is not free and we as developers should be more cautious than others. 😊

Thread Thread
rhymes profile image
rhymes

True that! Privacy is paramount these days. Companies are out there doing shady things, like selling your location data or... being Facebook :D

Collapse
_darrenburns profile image
Darren Burns Author

Thanks Sarthak :)

Collapse
deadlydog profile image
Daniel Schroeder

Thanks for the great info!

Another awesome tip for reviewing pull requests is to append ?w=1 to the URL. This will make the pull request ignore whitespace changes :)

Also, if you want a more natural GitHub Pull Request review experience, check out the GitHub Pull Request extension for VS Code.

Collapse
_darrenburns profile image
Darren Burns Author

Looks awesome 😊

Collapse
irek02 profile image
Irek Mirgaleev

I will shamelessly promote my github extension for chrome that helps me reviewing large PRs where it shows a hierarchical view of all changed files so you can see the scope of changes at a glance: chrome.google.com/webstore/detail/...

Collapse
_darrenburns profile image
Darren Burns Author

Looks really cool! I'll give it a shot this week 🙂

Collapse
vberlier profile image
Collapse
mcataford profile image
Marc Cataford

Github is bursting with features, it's always good to revisit some favourites!

One thing that is important to keep in mind about the pull request suggestion feature: be careful if you have any sort of commit message linting (either in relationship with a semantic versioning system or just for the sake of standardization), I had to amend commit histories more than once after accepting a suggestion too hastily and using the default commit message.

While it's a useful feature for quick fixes, being able to disable it on a per-project basis could definitely save some headaches.

Collapse
_darrenburns profile image
Darren Burns Author

Totally agreed. I'd only use it for really small things that I'm confident won't result in a broken build.

I don't know that I'd disable it though. If you've got GitHub linked to a CI platform then in the worst case it should result in a single broken commit.

Collapse
mcataford profile image
Marc Cataford

True for the single broken commit, I'm just very averse to any variation of manual rebasing to be honest. In reality, fixing a broken commit history is actually a pretty straightforward process.

I wish that something like a user-defined commit message regexp could be set for repos though, it's a crude guardrail that could catch that kind of stuff.

Collapse
thorstenhirsch profile image
Thorsten Hirsch

Press ? to see the available keyboard shortcuts.

Collapse
robertcoopercode profile image
Robert Cooper

This article is absolute gold. Will definitely be using the t keyboard shortcut to search for files.

Collapse
_darrenburns profile image
Darren Burns Author

Thank you so much 🙂

Collapse
hisham profile image
Hisham Mubarak

I always wondered why there is a weird / on the search bar of github, now I know why. Awesome post. All of them are so helpful and I didn't know a single one of them, now I do. Thanks a lot.

Collapse
_darrenburns profile image
Darren Burns Author

Happy to hear that 🙂

Collapse
tcrammond profile image
Tyler Crammond

Great tips, I didn't know about the search hotkeys at all. Thanks

Collapse
peterwitham profile image
Peter Witham

Thanks, Darren, this list is a real gem of tips for all levels of GitHub users.

Collapse
_darrenburns profile image
Darren Burns Author

Thank you Peter.

Collapse
cpinkus profile image
Claudio Pinkus

Thanks Darren for the tips. I would like to know if you checked CodeStream, our IDE extension for VS Code, Visual Studio and Jetbrains editors that does some of these things and also includes PRs in your IDE with the ability to add comments on any line of code, not only what's changed. Would love your feedback!

Collapse
cmmata profile image
Carles Mata

Great post! I'll take note of almost all your tips.

Collapse
_darrenburns profile image
Collapse
dr4gonandroiddev profile image
dr4gon

This is fantastic! Keep up the good work!

Collapse
shayd16 profile image
Shayne Darren

Any idea if you can get Octotree working for GitHub enterprise(privately hosted)?

Collapse
_darrenburns profile image
Darren Burns Author

You can use it with if you grant the correct permissions. Here's a guide:

github.com/ovity/octotree#enterpri...

Hope that helps :)

Collapse
shikaan profile image
Manuel Spagnolo

And unfortunately only on Chrome :/ No way for me to make it work on firefox

Collapse
acostalima profile image
André Costa Lima

Thanks for the valuable tips. 👌
Wasn't aware at all of some of these.

Collapse
_darrenburns profile image
Darren Burns Author

You're welcome 🙂

Collapse
tcelestino profile image
Tiago Celestino

I did know about "suggestions" and "saved replies", they are amazing.

I recommend also the Refined GitHub.

Thanks for tips!

Collapse
fannyvieira profile image
Fanny

Thanks!

Collapse
darryl profile image
Darryl Young

Great post, Darren. Thanks for sharing.

Collapse
tvanantwerp profile image
Tom VanAntwerp

I had no idea about the suggested revision feature--going to start using that a lot. Thanks for sharing!

Collapse
_darrenburns profile image
Darren Burns Author

It's pretty helpful for quick fixes 😄

Collapse
kylegalbraith profile image
Kyle Galbraith

Great post Darren! I use a few these in my day to day.

Collapse
pavlosisaris profile image
Paul Isaris

Awesome article, thanks!

Collapse
idoshamun profile image
Ido Shamun

Genius tips! Thanks :)

Collapse
_darrenburns profile image
Darren Burns Author

You're welcome! Glad you enjoyed it Ido 🙂

Collapse
nholden profile image
Nick Holden

Awesome list, Darren! ✨

I didn't know about the hotkey to search for functions in code changes. Going to give it a shot this week!

Collapse
_darrenburns profile image
Darren Burns Author

Thanks Nick 😄

Collapse
lelethebest profile image
Emanuele

Cool post, thanks :)

Collapse
gruser profile image
GruSer

Thanks for the interesting information...

Collapse
aditya profile image
Aditya Rao

Thanks for octotree and fuzzy file search. Never knew GitHub has such gems.

Collapse
_darrenburns profile image
Darren Burns Author

Glad I could introduce you to some new features!

Collapse
afifalfiano profile image
Collapse
pda_code profile image
Collapse
cpinkus profile image
Claudio Pinkus

Thanks @_darrenburns for this! Have you checked the CodeStream extension for VS Code, VS and Jetbrains? (Disclaimer - I work there). Would love to get your impression.

Collapse
ashchk profile image
Ashis Chakraborty

Good tips...liked it

Collapse
dance2die profile image
Sung M. Kim

Thank you, Darren.

Love the compiled list and wasn't aware one can do so much more on GitHub 🙂

Collapse
_darrenburns profile image