Github is the largest open source community in the world. You can find thousands of code examples of your favorite programming languages on Github. I often search code examples on Github to understand how different people approach the similar problem. Let me show you how to effectively search code on Github.
Select Github code search
Use quotes for search queries with whitespace
"public function initialize"
languagequalifier to search the code based on the language it's written in
filenamequalifier matches code files with a certain filename
runningInConsole language:php filename:InteractsWithApplication
inqualifier to restrict your search to the contents of the code file, the file path, or both
userqualifier to search the code in all the public repositories owned by a given organization or by a certain user
Application in:path org:laravel
repo qualifier to search the code in a given repository
path qualifier to search for source code that appears at a specific location in a repository
Laravel repo:laravel/laravel path:public
extensionqualifier matches code files with a certain file extension
index org:laravel in:path extension:js
You can remove certain results by prefixing any search qualifiers with a hyphen
index org:laravel in:path extension:js -path:src
Github has a lot of other functions available to search for different types of information such as People, Issues, and projects. You can read the Github search docs to explore more.
If you do not prefer to remember and write all qualifiers for search manually, You can use the advanced Github search interface.
This article is inspired by Use Google like a pro by Marco Denic.