github代碼搜索技巧


 github是一個很是豐富的資源,可是面對這豐富的資源不少人不知到怎麼使用,更談不上怎麼貢獻給他,咱們須要使用github就要學習使用他的方法, 學會了使用的方法,接受了他的這種觀點咱們纔會慢慢的給他貢獻本身的力量,這是我本身在學習的時候的一個筆記。如今分享給你們但願可以對一些人有幫助。
 
Search / Searching code

github搜索之代碼搜索javascript

Searching code

代碼搜索css

To search for code, use the following search qualifiers in any combination.java

Tip: There's a list of search syntaxes you can add to any search qualifier to further improve your results.python

 

Considerations for code search

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

  • Only the git

    default branch github

    is considered. In most cases, this will be the shell

    master vim

    branch.ruby

  • Only files smaller than 384 KB are searchable.

  • You must always include at least one search term when searching source code. For example, searching for 

    language:go 

    is not valid, while 

    amazing language:go 

    is.

  • At most, search results can show two fragments from the same file, but there may be more results within the file.

  • You can't use the following wildcard characters as part of your search query:. , : ; / \ ` ' " = * ! ? # $ & + ^ | ~ < > ( ) { } [ ]. The search will simply ignore these symbols.

以上是代碼搜索中須要注意的一些問題

默認搜索是從master分支搜索代碼

只有小於384k的代碼纔是能夠搜索到的

搜索的時候必須包含至少一個搜索關鍵詞 如 amazing language:go

搜索語句不能有特殊字符如. , : ; / \ ` ' " = * ! ? # $ & + ^ | ~ < > ( ) { } [ ].

 

 

Scope the search fields

指定搜索方式

 

  • octocat in:file

  • Matches code where "octocat" appears in the file contents.

  • 搜索文件中有octocat的代碼

  • octocat in:path

  • Matches code where "octocat" appears in the path name.

  • 搜索路徑中有octocat的代碼

  • octocat in:file,path

  • Matches code where "octocat" appears in the file contents or the path name.

  • 搜索路徑中有octocat的代碼或者文件中有octocat的代碼

  • display language:scss

  • Matches code with the word "display," that's marked as being SCSS.

  • 搜索用scss寫的包含display的代碼

  • Integer

  • Matches code with the word "Integer".

  • 搜索包含Integer的字段

  • Search 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 100 bytes.

  • 搜索大小爲100字節的xml代碼

  • user:mozilla language:markdown

  • Matches code from all @mozilla 's repositories that's marked as Markdown.

  • 搜索mozilla用戶下用markdown寫的代碼

  • Search by the number of forks the parent repository has

    經過fork的數量或者是否有父節點的方式搜索

     

    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.

  • 搜索用java寫的 android相關的代碼而且被fork過

  • 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 are larger than 10 KB.

  • 搜索與function相關的python代碼,文件大小超過10kb

  • Search by the location of a file within the repository

    按照目錄結構搜索

    By including the path qualifier, you specify that resulting source code must appear at a specific location in a repository. Subfolders are considered during the search, so be as specific as possible. For example:

  • console path:app/public language:javascript

  • Finds JavaScript files with the word "console" in an 

    app/public 

    directory (even if they reside inapp/public/js/form-validators).

  • app/public 

    directory目錄下搜索console關鍵字

  • form path:cgi-bin language:perl

  • Finds Perl files under 

    cgi-bin 

    with the word "form" in them.

  • 搜索cgi-bin目錄下包含form的perl代碼

  • Search by filename

    經過文件名搜索

    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.

  • 搜索 文件名匹配*.vimrc* 而且包含commands的代碼

  • minitest filename:test_helper path:test language:ruby

  • Finds Ruby files containing the word "minitest" named *test_helper* within the *test* directory.

  • 在test目錄中搜索包含minitest且文件名匹配"*test_helper*"的代碼

  • Search by the file 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.

  • 搜索cgi-bin目錄下以pm爲擴展名的代碼

  • icon size:>200000 extension:css

  • Finds files larger than 200 KB that end in 

    .css 

    and have the word "icon" in them.

  • 搜索超過200kb包含icon的css代碼

  • Search within a user's or organization's repositories

    經過用戶或者組織來查找

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

  • user:github extension:rb

相關文章
相關標籤/搜索