GitHub Code Search Tips

Source: Internet
Author: User

GitHub is a very rich resource, but in the face of this rich resources many people do not know how to use, let alone how to contribute to him, we need to use GitHub to learn how to use his methods, learn how to use the method, accept his view of this we will slowly give him the power to contribute , this is a note of my own while studying. Now it's time to share it with people who want to help.  Search /Searching code

GitHub Search Code Search

Searching Code

Code Search

To search for code with the following search qualifiers in any combination.

Tip: There ' s a list of search syntaxes You can add to all search qualifier to further improve your R Esults.

 Considerations for Code Search

Due to the complexity of searching code, there is a few restrictions on how searches is performed:

  • the default branch is considered. In most cases, this would be the master Branch.
  • Only files smaller than 384 KB is searchable.
  • You must always include at least one search term when searching source code. For example, searching language:go for are not valid, and while is amazinglanguage:go .
  • At most, search results can show on fragments from the same file, but there may is more results within the file.
  • You can ' t use the following wildcard characters as part of the Your search query: ., : ; / \ ` ‘ " = * ! ? # $ & + ^ | ~ < > ( ) { } [] . The search would simply ignore these symbols.

These are some of the issues that need to be noted in code search

The default search is to search for code from the master branch

Only less than 384k of code is available to search.

Search must include at least one search keyword如amazing language:go

Search statements cannot have special characters such as ., : ; / \ ` ‘ " = * ! ? # $ & + ^ | ~ < > ( ) { } [] .

Scope the Search fields

Specify Search methods

Octocat In:file
Matches code where "Octocat" appears in the file contents.
search for code with OCTOCAT in the file
Octocat In:path
Matches code where "Octocat" appears in the path name.
code with Octocat in the search path
Octocat In:file,path
Matches code where "Octocat" appears in the file contents or the path name.
octocat code in the search path or Octocat code in the file
Display LANGUAGE:SCSS
Matches code with the word "display," that's marked as being SCSS.
search for code written with Scss that contains display
Integer
Matches code with the word "Integer".
search for fields that contain integers
Search by language

Search for code by language

You can search for code based on what language it's written in. For example:

Element Language:xml size:100
Matches code with the word "element", that's marked as being XML and has exactly bytes.
Search for XML code with a size of 100 bytes
User:mozilla Language:markdown
Matches code from all @mozilla ' s repositories, marked as Markdown.
Search for Mozilla user code written in Markdown
Search by the number of forks the parent repository have

Search by the number of fork or whether there is a parent node

If you would like forked results to appear, add the fork:true qualifier. For example:

Android Language:java Fork:true
Matches code in a forked repository with the word "Android" that's written in Java.
Search for Android-related code written in Java and fork over

the size Qualifier Filters results based on the size of the file in which the code is found. For example:

function size:>10000 Language:python
Matches code with the word ' function, ' written in Python, ' in ' files that is larger than ten KB.
Search and fun ction-related Python code with file size greater than 10KB
Search By the location of a file within the repository

Search by directory structure

by including the  Path   qualifier, you specify this resulting source code must appear at a specific location in a repository. Subfolders is considered during the search, so is as specific as possible. For example:

Console Path:app/public Language:javascript
Finds JavaScript files with the word "console" under an app/public directory (even if they res IDE in app/public/js/form-validators).
Search the console keyword under the app/public Directory Catalog
Form Path:cgi-bin Language:perl
Finds Perl files under cgi-bin with the word "form" in them.
Search for Perl code containing form in the Cgi-bin directory
Search by filename

Search by file name

You can use the filename Qualifier If there ' s a specific file you ' re looking for. For example:

FILENAME:.VIMRC commands
Finds *.vimrc* files with the word "commands" in them.
search file name matches *.vimrc* and contains commands code
Minitest Filename:test_helper path:test Language:ruby
Finds Ruby files containing the word "minitest" named *test_helper* within the *test* directory.
Search for code in the test directory that contains minitest and the file name matches "*test_helper*"
Search by the
file extension

Search for code by extension

the extension qualifier matches code files with a certain extension. For example:

Form Path:cgi-bin EXTENSION:PM
Matches code with the word "form," under cgi-bin, with the . PM Extension .
search for code with a PM extension under the Cgi-bin directory
Icon size:>200000 extension:css
Finds files larger than KB that end in . css and has the word "icon" in THEM.
search over 20 0KB CSS Code with icon
Search Within a user s or organization ' s repositories

find

to grab a list of code from all repositories owned by a Certain user or organization, you can use the  user syntax. For getting a list of code from a specific repository, you can use the  repo   syntax. F or example:

User:github EXTENSION:RB

GitHub Code Search Tips

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.