Skip to main content
Frecuentemente publicamos actualizaciones de nuestra documentación. Es posible que la traducción de esta página esté en curso. Para conocer la información más actual, visita la documentación en inglés. Si existe un problema con las traducciones en esta página, por favor infórmanos.

Esta versión de GitHub Enterprise se discontinuó el 2022-06-03. No se realizarán lanzamientos de patch, ni siquiera para problemas de seguridad críticos. Para obtener un mejor desempeño, más seguridad y nuevas características, actualiza a la última versión de GitHub Enterprise. Para obtener ayuda con la actualización, contacta al soporte de GitHub Enterprise.

Searching code

You can search for code on GitHub Enterprise Server and narrow the results using these code search qualifiers in any combination.

Puedes buscar globalmente en todo GitHub Enterprise Server o limitar tu búsqueda a un repositorio o a una organización en particular For more information, see "About searching on GitHub."

You can only search code using these code search qualifiers. Search qualifiers specifically for repositories, users, or commits, will not work when searching for code.

Tips:

  • Este artículo contiene enlaces a las búsquedas de muestra en el sitio web de GitHub.com, pero puedes utilizar los mismos filtros de búsqueda con GitHub Enterprise Server. En las búsquedas de ejemplos vinculadas, reemplaza github.com con el nombre de host para tu instancia de GitHub Enterprise Server.
  • Para obtener una lista de sintaxis de búsqueda que puedas agregar a cualquier calificador para mejorar aún más tus resultados, consulta "Comprender la sintaxis de búsqueda".
  • Utiliza comillas alrededor de los términos de búsqueda que contengan varias palabras. Por ejemplo, si deseas buscar propuestas con la etiqueta "In progress" (En curso), buscarías por la etiqueta label:"in progress". Buscar no distingue entre mayúsculas y minúsculas.

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

  • Debes haber iniciado sesión en una cuenta personal en GitHub Enterprise Server para buscar código en todos los repositorios públicos.
  • Code in forks is only searchable if the fork has more stars than the parent repository. Forks with fewer stars than the parent repository are not indexed for code search. To include forks with more stars than their parent in the search results, you will need to add fork:true or fork:only to your query. For more information, see "Searching in forks."
  • Only the default branch is indexed for code search.* Only files smaller than 5 MB are searchable.
  • Only the first 500 KB of each file is searchable.
  • Up to 4,000 private and internal repositories are searchable. These 4,000 repositories will be the most recently updated of the first 10,000 private and internal repositories that you have access to.
  • Only repositories with fewer than 500,000 files are searchable.
  • Except with filename searches, you must always include at least one search term when searching source code. For example, searching for language:javascript is not valid, while amazing language:javascript 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.

Search by the file contents or file path

With the in qualifier you can restrict your search to the contents of the source code file, the file path, or both. When you omit this qualifier, only the file contents are searched.

QualifierExample
in:fileoctocat in:file matches code where "octocat" appears in the file contents.
in:pathoctocat in:path matches code where "octocat" appears in the file path.
octocat in:file,path matches code where "octocat" appears in the file contents or the file path.

Search within a user's or organization's repositories

To search the code in all repositories owned by a certain user or organization, you can use the user or org qualifier. To search the code in a specific repository, you can use the repo qualifier.

QualifierExample
user:USERNAMEuser:defunkt extension:rb matches code from @defunkt that ends in .rb.
org:ORGNAMEorg:github extension:js matches code from GitHub that ends in .js.
repo:USERNAME/REPOSITORYrepo:mozilla/shumway extension:as matches code from @mozilla's shumway project that ends in .as.

Search by file location

You can use the path qualifier to search for source code that appears at a specific location in a repository. Use path:/ to search for files that are located at the root level of a repository. Or specify a directory name or the path to a directory to search for files that are located within that directory or any of its subdirectories.

QualifierExample
path:/octocat filename:readme path:/ matches readme files with the word "octocat" that are located at the root level of a repository.
path:DIRECTORYform path:cgi-bin language:perl matches Perl files with the word "form" in the cgi-bin directory, or in any of its subdirectories.
path:PATH/TO/DIRECTORYconsole path:app/public language:javascript matches JavaScript files with the word "console" in the app/public directory, or in any of its subdirectories (even if they reside in app/public/js/form-validators).

Search by language

You can search for code based on what language it's written in. The language qualifier can be the language name or alias. For a full list of supported languages with their names and aliases, see the github/linguist repository.

QualifierExample
language:LANGUAGEelement language:xml size:100 matches code with the word "element" that's marked as being XML and has exactly 100 bytes.
display language:scss matches code with the word "display," that's marked as being SCSS.
org:mozilla language:markdown matches code from all @mozilla's repositories that's marked as Markdown.

Search by file size

You can use the size qualifier to search for source code based on the size of the file where the code exists. The size qualifier uses greater than, less than, and range qualifiers to filter results based on the byte size of the file in which the code is found.

QualifierExample
size:nfunction size:>10000 language:python matches code with the word "function," written in Python, in files that are larger than 10 KB.

Search by filename

The filename qualifier matches code files with a certain filename. You can also find a file in a repository using the file finder. For more information, see "Finding files on GitHub."

QualifierExample
filename:FILENAMEfilename:linguist matches files named "linguist."
filename:.vimrc commands matches .vimrc files with the word "commands."
filename:test_helper path:test language:ruby matches Ruby files named test_helper within the test directory.

Search by file extension

The extension qualifier matches code files with a certain file extension.

QualifierExample
extension:EXTENSIONform path:cgi-bin extension:pm matches code with the word "form," under cgi-bin, with the .pm file extension.
icon size:>200000 extension:css matches files larger than 200 KB that end in .css and have the word "icon."

Further reading