Как найти код на github

Правильный поиск по GitHub поможет вам найти нужного разработчика или нужный репозиторий с кодом. GitHub — это один из тех сервисов, которые не нужно представлять людям, хоть немного связанным с программированием. Это ресурс, на котором каждый программист просто обязан иметь аккаунт, потому что большинство современных компаний, прежде чем нанимать к себе разработчика, проверяют его профиль на GitHub. Если в профиле «есть что посмотреть» и на самом ресурсе программист проявлял активность, то это приносит ему много плюсов в резюме.

На сегодняшний день на GitHub зарегистрировано более 35 миллионов аккаунтов, поэтому поиск нужного программиста именно по этому сервису более чем оправдан. Плюс ко всему GitHub — это огромная площадка, где разработчики размещают код своих работающих приложений, которые распространяются по свободной лицензии. То есть GitHub — это огромное хранилище исходников, поэтому поиск нужного кода или репозитория по этому ресурсу тоже более чем оправдан.

 

Поиск кода или разработчика по GitHub

Искать разработчика или нужный код можно разными путями. Например, разработчиков можно искать на специализированных сайтах по поиску работы, таких как hh.ru. Когда нужен код, можно воспользоваться специальным форумом или попросить помощи у других программистов. Но и в том и в другом случае очень правильно будет вести поиск по GitHub, ведь это один их тех ресурсов, где сконцентрированы лучшие программистские умы.

 

Поиск кода или репозитория по GitHub

Поиск нужного кода по GitHub может пригодиться в разных ситуациях. Если же вам нужен исходный код какой-либо программы, то, возможно, вам нужно искать его не на самом GitHub, а на официальном сайте той же программы, если она, конечно, распространяется с открытым исходным кодом. Обычно программы с открытыми исходниками сами оставляют ссылки на свои архивы.

Если же у вас другая ситуация, то можно воспользоваться внутренним поиском самого GitHub. Первым делом вам нужно будет позаботиться о наличии аккаунта на данной площадке, чтобы вы могли искать по всем доступным репозиториям. Когда вам нужно осуществить поиск по всему GitHub, то необходимо воспользоваться глобальной поисковой строкой на самой площадке. Если вы знаете, репозитории какой организации вы хотите найти, то можно осуществить поиск по GitHub внутри конкретной организации.

Поиск репозитория можно выполнить по следующим идентификаторам:

  • in:name поиск по имени репозитория, то есть искомые слова будут искаться в наименовании репозиториев;

  • in:description — поиск по описанию репозитория на совпадение указанных слов поиска именно в описании;

  • in:readme — поиск по файлам README;

  • repo:owner/name — поиск по точному совпадению имени репозитория.

Также можно осуществить поиск нужного репозитория по GitHub:

  • по размеру репозитория;

  • по количеству подписчиков;

  • по количеству вилок;

  • по количеству звезд;

  • по дате создания;

  • по дате последнего обновления;

  • по используемому языку программирования;

  • по теме;

  • по количеству тем;

  • по лицензии;

  • по видимости репозитория;

  • по наличию проблем с репозиторием;

  • по возможности оказать спонсорскую помощь;

  • и др.

Как видите, вариантов поиска нужного репозитория по GitHub очень много, поэтому вы обязательно сможете найти то, что ищите.

 

Поиск разработчиков по GitHub

Итак, мы условились, что GitHub — это специализированный ресурс для разработчиков разного уровня, поэтому искать там нужного программиста — это нормально. Здесь работает такой же принцип, как и с поиском репозиториев, — нужно обязательно быть зарегистрированным на GitHub, иначе найти нужного разработчика не получится.

Как только зарегистрируетесь, вам станет доступно множество вариантов поиска нужного разработчика. Важно отметить, что некоторые способы поиска идентичны поиску репозиториев, и именно их изначально вам выдаст GitHub. Чтобы искать именно разработчиков, переключите результаты поиска на категорию «Users». 

Среди всех популярных вариантов поиска разработчиков отметим следующие:

  1. Поиск по ключевым словам. К примеру, если вам необходим python-разработчик, то введите в поиске слово «python».

  2. Поиск по языкам программирования, которыми должен обладать искомый разработчик. Введите в поисковой строке любой язык программирования, и GitHub выдаст вам результат.

  3. Поиск по технологиям. Работает так же, как и с языками программирования: просто введите название необходимого фреймворка, который не является самостоятельным языком программирования.

  4. Искать по активности программиста. Обычно этот вид поиска осуществляют, когда уже нашли список потенциальных кандидатов, допустим, по языку программирования. Далее в качестве фильтра можно отсеять тех, кто давно не проявлял активность на GitHub.

Программист на GitHub не всегда заинтересован в поиске новой работы — нужно помнить об этом. Второй момент: не все программисты на GitHub те, за кого себя выдают, поэтому важно с потенциальными кандидатами познакомиться и побеседовать лично, чтобы можно было поподробнее расспросить о скиллах, которыми обладает найденный разработчик. Ведь на GitHubработает принцип любой соцсети — написать о себе можно много чего, также можно в своих репозиториях держать совсем не свой код и т. д.

 

Заключение

Поиск нужного кода или разработчика по GitHub — это логичное действие, потому что подобных специализированных площадок для программистов не так много. Вернее, они есть, но они не такого уровня, как GitHub.

С поиском кода вроде все ясно, поэтому сложностей возникнуть не должно. Тем более раз вы ищите код, то вы в нем как минимум разбираетесь. Сложнее с поиском разработчиков, потому что на GitHub очень много «пустышек», которые просто будут отнимать у вас время.

Update May 2023:

The new code search and code view is now generally available (May. 2023)

At GitHub Universe last year, we announced a total redesign of GitHub’s code search and navigation experience, powered by our all-new code search engine that we built from scratch.
And in February, we announced our public beta.

Today, we are rolling out this feature to all GitHub users.

https://i0.wp.com/user-images.githubusercontent.com/78169714/236855021-b5f60b03-78e4-46ac-a89d-7712cfb85aca.png?ssl=1 -- Screenshot of code search results

Check out our blog post to learn more about how GitHub’s new code search and code view can help you search, navigate, and understand your code.
And if you have feedback, please share it with us in our feedback discussion.


Update Dec. 2021: search has been improved again, with Search for an exact string, with support for substring matches and special characters, or regexps.

regex

But only on cs.github.com, and still in beta (waitlist applies)


Update January 2013: a brand new search has arrived!, based on elasticsearch.org:

A search for stat within the ruby repo will be expressed as stat repo:ruby/ruby, and will now just workTM.
(the repo name is not case sensitive: test repo:wordpress/wordpress returns the same as test repo:Wordpress/Wordpress)

enter image description here

Will give:

enter image description here

And you have many other examples of search, based on followers, or on forks, or…


Update July 2012 (old days of Lucene search and poor code indexing, combined with broken GUI, kept here for archive):

The search (based on SolrQuerySyntax) is now more permissive and the dreaded “Invalid search query. Try quoting it.” is gone when using the default search selector “Everything”:)

(I suppose we can all than Tim Pease, which had in one of his objectives “hacking on improved search experiences for all GitHub properties”, and I did mention this Stack Overflow question at the time 😉 )

Here is an illustration of a grep within the ruby code: it will looks for repos and users, but also for what I wanted to search in the first place: the code!

GitHub more permissive search results


Initial answer and illustration of the former issue (Sept. 2012 => March 2012)

You can use the advanced search GitHub form:

  • Choose Code, Repositories or Users from the drop-down and
  • use the corresponding prefixes listed for that search type.

For instance, Use the repo:username/repo-name directive to limit the search to a code repository.
The initial “Advanced Search” page includes the section:

Code Search:

The Code search will look through all of the code publicly hosted on GitHub. You can also filter by :

  • the language language:
  • the repository name (including the username) repo:
  • the file path path:

So if you select the “Code” search selector, then your query grepping for a text within a repo will work:

Good Search selector


What is incredibly unhelpful from GitHub is that:

  • if you forget to put the right search selector (here “Code“), you will get an error message:
    Invalid search query. Try quoting it.

Wrong selector for the code filer

  • the error message doesn’t help you at all.
    No amount of “quoting it” will get you out of this error.

  • once you get that error message, you don’t get the sections reminding you of the right association between the search selectors (“Repositories“, “Users” or “Language“) and the (right) search filters (here “repo:“).
    Any further attempt you do won’t display those associations (selectors-filters) back. Only the error message you see above…
    The only way to get back those arrays is by clicking the “Advance Search” icon:

Advance Search Icon on GitHub

  • the “Everything” search selector, which is the default, is actually the wrong one for all of the search filters! Except “language:“…
    (You could imagine/assume that “Everything” would help you to pick whatever search selector actually works with the search filter “repo:“, but nope. That would be too easy)

  • you cannot specify the search selector you want through the “Advance Search” field alone!
    (but you can for “language:“, even though “Search Language” is another combo box just below the “Search for” ‘type’ one…)

Wrong search selector


So, the user’s experience usually is as follows:

  • you click “Advanced Search“, glance over those sections of filters, and notice one you want to use: “repo:
  • you make a first advanced search “repo:jruby/jruby stat“, but with the default Search selector “Everything
    => FAIL! (and the arrays displaying the association “Selectors-Filters” is gone)
  • you notice that “Search for” selector thingy, select the first choice “Repositories” (“Dah! I want to search within repositories…”)
    => FAIL!
  • dejected, you select the next choice of selectors (here, “Users“), without even looking at said selector, just to give it one more try…
    => FAIL!
  • “Screw this, GitHub search is broken! I’m outta here!”

    (GitHub advanced search is actually not broken. Only their GUI is…)

So, to recap, if you want to “grep for something inside a Github project’s code”, as the OP Ben Humphreys, don’t forget to select the “Code” search selector…

Searching through code on Github

Github has just released the first preview version of its new search engine to look up code in your repositories. It’s called “Github Code Search” and provides a fuzzy-like search experience for your content on Github repositories. It crawls the repos and returns results that show the matching code lines.

As I noted, the service is currently in preview. I’m lucky to be one of the testers, but at the time of reading this article, Github Code Search might already be available to the general public.

Finding code among repos

The most basic yet also most powerful feature of Github Code Search is that you can just provide a query string and the engine will show you the relevant matches among all public repositories. Yes, you’ve read that correctly: the search returns results from not only your repositories, but all public ones by default.

All you have to do is enter the search parameter and hit enter on your keyboard. The next view will render all matches.

Of course, you can limit the search to only inspect your account’s content. This can either be done by using the prefix “owner:” to your query or by selecting your account from the left dropdown button in the search bar.

If you define the scope via the dropdown button to your account, the results get also rendered inline as a list, which is really nice for doing quick searches without changing the page.

Github’s custom query language

A more advanced feature of Github Code Search is the ability to precisely define the scope of the search via regular expressions, file paths as well as boolean operators. All together they allow you to write queries in a simple but quite efficient language.

As this is only the first iteration of the service, I’m sure Github Code Search will become much more powerful in the future. After using it for some time during the preview phase I can already say that it will be one of the most used features on Github.

I also think that Github Code Search can evolve into a competitor to Stack Overflow when it comes to searching for code snippets or templates – a feature that might already be covered by Github Copilot.

GitHub Search Tips – How to Search Issues, Repos, and More Effectively on GitHub

When I was a beginner to open-source contributions, one of my greatest challenge was finding the correct projects/issues to work on.

For the longest time I relied on resources curated by different writers on the internet (which were good, by the way). But I always wanted to find a way around this problem – a way I could search for and track projects that were right for my skill set.

Let’s agree on one thing: unlike Google, searching GitHub is not easy. But as a developer, chances are that you’ll interacting with GitHub or Gitlab on a daily basis.

Now the question isn’t what you use these version control systems for, but how you are using them. Just like mastering Google search skills is essential for any regular internet user, I believe it’s also essential for developers to learn how to effectively search GitHub.

In this article we are going to take a look at different techniques you can use to correctly search GitHub. You’ll learn how to search through:

  • Issues and Pull Requests
  • Repositories
  • Users
  • Topics

And more. Let’s get started.

GitHub Search Queries

In order to find detailed information about something on the internet, you need to have the correct searching skills. It’s not any different with GitHub – to find detailed info you can utilize common filter, sort, and searching techniques to easily find specific issues and pull requests of a given project.

Even though you have multiple resources listed on the internet for different projects, the main problem comes in when you want to do a search by yourself. How do you get started? Which keywords should you use to find the correct results?

Most maintainers tend to label their projects with issues, which makes it easier for contributors to find suitable projects. Listed below are some of the tricks that might help you out when you are using GitHub.

How to Search Issues and Pull Requests on GitHub

One of the most common ways of finding projects to contribute to is by searching through issues and related PRs. Here are some tricks you can use to easily find reliable answers:

  1. is:issue is:open label:beginner – This particular query will list all projects with issues that are open and labeled beginner.
  2. is:issue is:open label:easy – This will list all open issues that are labeled easy.
  3. is:issue is:open label:first-timers-only – This lists all open issues that welcome first-timer contributions.
  4. is:issue is:open label:good-first-bug – This lists projects with open issues labeled good-first-bug, to attract contributors to work on them.
  5. is:issue is:open label:”good first issue” – This will list all open issues with the label good first issue, meaning it is good for place for beginners to get started.
  6. is:issue is:open label:starter – This lists all open issues from across GitHub that are labeled starter.
  7. is:issue is:open label:up-for-grabs – This lists open issues that are ready to be worked on if you have the necessary skills.
  8. no:project type:issue is:open – This will list all open issues that are not assigned to a specific project.
  9. no:milestone type:issue is:open – Many times, projects are tracked with milestones. But if you want to find issues that are not tracked, this search query will list those projects for you.
  10. no:label type:issue is:open – This lists all open issues that are not labeled.
  11. is:issue is:open no:assignee – This shows all open issues that have not yet been assigned to a person.

How to Search Repositories

By default, to make a search you will type the repository name in the search bar and voilà! You get some search results.

But the chances of you landing on the exact repo you intended are very low.

Let’s look at some ways you can narrow down your search:

How to Find by Name, Description/README

A thing to note when you search by Name and description of the README file is that your search phrase should begin with the in qualifier. This makes it possible to search “inside” what you are looking for.

Example

  • Using in:name. Let’s say you are looking for resources to learn more about Data Science. In this case, you can use the command Data Science in:name which will list repositories with Data Science in the repository name.

  • Using in:description. If you want to find repositories with a ceratin description, for example repositories where the term “freeCodeCamp” is included in the descriptionm, our search will be: freecodecamp in:description

  • Using in:readme. You use this to search through a README of a file for a certain phrase. If we want to find repositories where the term freecodecamp is included in the README, our search will be: freecodecamp in:readme.

  • Using in:topic. You use this to find if a certain phrase or word is labeled in the topics. For example to find all repositories where freecodecamp is listed in the topic, our search will be: freecodecamp in:topic

You can also combine multiple search queries to further narrow down the search.

How to Find by Stars, Forks

You can also search for a repository based on how many stars and forks the project has. This makes it easier for you to know how popular the project is.

Examples

  • Using stars:n. If you search for a repository with 1000 stars, then your search query will be stars:1000. This will list repositories with exactly 1000 stars.

  • Using forks:n. This specifies the number of forks a repository should have. If you want find repositories that have less than 100 forks, your search will be: forks:<100.

The good thing is that you can always use relational operators like <, >, <=, >= & .. to help you further narrow your search.

How to Find by Language

Another cool way to search through GitHub is by language. This helps you filter out repositories to a specific language.

Example:

  • Using language:LANGUAGE. For example if you want to find repositories written in PHP, your search will be: language:PHP

How to Find by Organization Name

You can also search repositories/projects that are maintained or created by a specific organization. For this you need to begin your search with the keyword org:... followed by the organization name.

For example if you search org:freecodecamp it will list repositories that match freeCodeCamp.

How to Find by Date

If you want your results based on a specific date, you can search using one of these keywords: created, updated, merged and closed. These keywords should be accompanied by date in the format YYYY-MM-DD.

Example:

  • Using keyword:YYYY-MM-DD. Take an instance where we want to make a search of all repositories with the word freeCodeCamp that were created after 2022-10-01. Then our search will be: freecodecamp created:>2022-10-01

You can also use <, >, >= and <= to search for dates after, before and on the specified date. To search within a range you can use ....

How to Find by License

Licenses are very important when you are are looking for a project to contribute to. Different licenses give different rights as to what a contributor can do or can not do.

To make it easier for you to find projects with right licenses you need to have a good understanding of licenses. You can read more about them here.

Example:

  • Using license:LICENSE_KEYWORD. This is a good way to search for projects with specific licenses. To search projects with the MIT license, for instance, you would do license:MIT.

How to Find by Visibility

You can also conduct your search in terms of the visibility of the repository. In this case you can either use public or private. This will match issues and PRs that are either in a public or private repository, respectively.

Examples:

  • Using is:public. This will show a list of public repositories. Let’s take an isntance where we want to search all public repositories owned by freeCodCamp. Then our search will be: is:public org:freecodecamp.
  • Using is:private. This query is meant to lists all private repositories under the given search query.

Conclusion

Even though we have covered many search queries here, you can always be creative to further narrow your search by combining multiple parameters together.

For additional resources and more search parameters, you can always refer to the GitHub Docs or make use of Advanced GitHub Search. These methods will always come in handy as they offer more filering options.

There are a ton of search parameters you can use to make your daily activity around GitHub easier. Hopefully this will help you use the platform more easily and effectively.



Learn to code for free. freeCodeCamp’s open source curriculum has helped more than 40,000 people get jobs as developers. Get started

Today, we are rolling out a technology preview for substantial improvements to searching code on GitHub. We want to give you an early look at our efforts and get your feedback as we iterate on helping you explore and discover code—all while saving you time and keeping you focused. Sign up for the waitlist now, and give us your feedback!

Getting started

Once the technology preview is enabled for your account, you can try it out at https://cs.github.com. Initially, we’re creating a separate interface for the new code search as we build it out, but once we’re happy with the feedback and are ready for wider adoption, we will integrate it into the main github.com experience.

At the moment, the search index covers more than five million of the most popular public repositories; in addition, you can search private repositories you have access to. Here are some things to look out for:

  • Easily find what you’re looking for among the top results, with smart ranking and an index that is optimized for code.
  • Search for an exact string, with support for substring matches and special characters, or use regular expressions (enclosed in / separators).
  • Scope your searches with org: or repo: qualifiers, with auto-completion suggestions in the search box.
  • Refine your results using filters like language:, path:, extension:, and Boolean operators (OR, NOT). Search for definitions of a symbol with symbol:.
  • Get your bearings quickly with additional features, like a directory tree view, symbol information for the active scope, jump-to-definition, select-to-search, and more!

The syntax is documented here, and you can press ? on any page to view available keyboard shortcuts. You can also check out the FAQs.

What’s next?

We’re excited to share our work with you as a technology preview while we iterate, and to work with you to find unique, novel use cases and workflows. What radical new idea have you always wanted to try? What feature would make you most productive? Is support for your favorite language missing? Let us know, and let’s make it happen together.

We have no shortage of ideas for what to focus on next. We’ll be growing the index until it covers every repository you can access on GitHub. We’ll experiment with scoring and ranking heuristics to see what works best, and we’ll explore what APIs and integrations would be most impactful. We’ll keep adding support for more languages to the language-specific features. But most of all, we want to listen to your feedback and build the tools you didn’t even know you needed.

The bigger picture: developer productivity at GitHub

As a developer, staying in a flow state is hard. Whenever you look up how to use a library, or have a test fail because your developer environment has diverged from CI, or need to know how an error message can arise, you are interrupted. The longer it takes to resolve the interruption, the more context you lose.

Earlier this year, we launched GitHub Copilot as a technical preview, leveraging the power of AI to let you code confidently even in unfamiliar territory. We also released Codespaces and shared how adopting them internally boosted GitHub’s own productivity. We see our improvements to code search and navigation in the context of these broader initiatives around developer productivity, as part of a unified solution.

For code search, our vision is to help every developer search, discover, navigate, and understand code quickly and intuitively. GitHub code search puts the world’s code at your fingertips: everything is just a search away. It helps you maintain a flow state by showing you the most relevant results first and helping you with auto-completion at every step. And once you get to a result page, the rich browsing experience is optimized for reading and understanding code, allowing you to make sense of unfamiliar logic quickly, even for code outside your IDE.

We plan to share more updates on our progress soon, including deep-dives on the engineering work behind code search and the developers, open source projects, and communities we rely on (special shout-out to @BurntSushi and @lemire, whose work has been fundamental to ours). In the meantime, the number of spots for the technology preview is limited, so sign up today!

Explore more from GitHub

Engineering

Engineering

Posts straight from the GitHub engineering team.

Learn more

The ReadME Project

The ReadME Project

Stories and voices from the developer community.

Learn more

GitHub Actions

GitHub Actions

Native CI/CD alongside code hosted in GitHub.

Learn more

Work at GitHub!

Work at GitHub!

Check out our current job openings.

Learn more

Subscribe to The GitHub Insider

A newsletter for developers covering techniques, technical guides, and the latest product innovations coming from GitHub.

Добавить комментарий