github-search
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGitHub Search
GitHub 搜索
Quick Commands
快速命令
| Goal | Command |
|---|---|
| Search repos | |
| Search code | |
| Search issues | |
| Search PRs | |
| 目标 | 命令 |
|---|---|
| 搜索仓库 | |
| 搜索代码 | |
| 搜索议题 | |
| 搜索拉取请求 | |
Direct API Search (Web-Exact Results)
直接API搜索(与网页结果完全一致)
For complex queries where gives different results than web:
gh search reposbash
undefined当的结果与网页端不一致时,可用于复杂查询:
gh search reposbash
undefinedTemplate - URL-encodes query automatically
模板 - 自动对查询内容进行URL编码
gh api "search/repositories?q=$(printf '%s' 'YOUR_QUERY_HERE' | jq -sRr @uri)&sort=updated&per_page=30" --jq '.items[].full_name'
**Example - Multi-language with exclusions:**
```bash
gh api "search/repositories?q=$(printf '%s' 'stars:>500 language:rust language:go language:TypeScript language:javascript -topic:ethereum -topic:cryptocurrency -topic:blockchain -topic:bitcoin -topic:web3' | jq -sRr @uri)&sort=updated&per_page=10" --jq '.items[].full_name'Why use this?
- is a convenience wrapper with its own query parsing
gh search repos - hits the raw API, matching web behavior exactly
gh api search/repositories - Required when combining: multiple languages + topic exclusions + star filters
Common jq extractions:
| Output | jq filter |
|---|---|
| Names only | |
| Full names | |
| With stars | |
| URLs | |
| Full JSON | (omit --jq) |
gh api "search/repositories?q=$(printf '%s' 'YOUR_QUERY_HERE' | jq -sRr @uri)&sort=updated&per_page=30" --jq '.items[].full_name'
**示例 - 多语言并排除指定主题:**
```bash
gh api "search/repositories?q=$(printf '%s' 'stars:>500 language:rust language:go language:TypeScript language:javascript -topic:ethereum -topic:cryptocurrency -topic:blockchain -topic:bitcoin -topic:web3' | jq -sRr @uri)&sort=updated&per_page=10" --jq '.items[].full_name'为什么使用该方式?
- 是一个便捷的封装工具,有自己的查询解析逻辑
gh search repos - 调用原生API,结果与网页端完全一致
gh api search/repositories - 当需要组合多语言、主题排除和星标筛选时必须使用
常用jq提取方式:
| 输出内容 | jq过滤器 |
|---|---|
| 仅名称 | |
| 完整名称 | |
| 带星标数量 | |
| 仓库URL | |
| 完整JSON数据 | (省略--jq参数) |
Patterns
使用模式
Finding Repositories
查找仓库
When you see: User wants to find projects/repos by criteria
Use:
gh search reposbash
undefined适用场景: 用户希望根据条件查找项目/仓库
使用命令:
gh search reposbash
undefinedBasic search with stars
带星标条件的基础搜索
gh search repos "stars:>500 language:rust" --sort=stars --limit=50
gh search repos "stars:>500 language:rust" --sort=stars --limit=50
Multiple languages (OR logic)
多语言搜索(或逻辑)
gh search repos "language:rust language:go language:typescript"
gh search repos "language:rust language:go language:typescript"
Exclude topics
排除指定主题
gh search repos "stars:>1000 -topic:cryptocurrency -topic:blockchain"
gh search repos "stars:>1000 -topic:cryptocurrency -topic:blockchain"
By topic
按主题搜索
gh search repos "topic:cli topic:terminal stars:>100"
gh search repos "topic:cli topic:terminal stars:>100"
Recently updated
查找近期更新的仓库
gh search repos "language:python pushed:>2024-01-01"
**Output formats:**
```bash
--json name,url,description,stargazersCount # JSON output
--web # Open in browsergh search repos "language:python pushed:>2024-01-01"
**输出格式:**
```bash
--json name,url,description,stargazersCount # JSON格式输出指定字段
--web # 在浏览器中打开结果Finding Code Examples
查找代码示例
When you see: User wants to know how to use a library
Use:
gh search codebash
undefined适用场景: 用户希望了解某个库的使用方式
使用命令:
gh search codebash
undefinedFind usage patterns
查找使用模式
gh search code "from zod import" --limit=20
gh search code "import { z } from 'zod'" --limit=20
gh search code "from zod import" --limit=20
gh search code "import { z } from 'zod'" --limit=20
In specific file types
按文件类型搜索
gh search code "useQuery" extension:tsx --limit=30
gh search code "useQuery" extension:tsx --limit=30
In specific paths
按文件路径搜索
gh search code "tanstack/query" path:src/ extension:ts
gh search code "tanstack/query" path:src/ extension:ts
Exact phrase
精确短语搜索
gh search code '"createTRPCRouter"' extension:ts
**Pro tip:** Combine with repo filter for focused results:
```bash
gh search code "pattern" repo:owner/repogh search code '"createTRPCRouter"' extension:ts
**专业提示:** 结合仓库过滤器获取精准结果:
```bash
gh search code "pattern" repo:owner/repoFinding Issues/Discussions
查找议题/讨论
When you see: User looking for bug reports, feature requests, or discussions
Use: or
gh search issuesgh search prsbash
undefined适用场景: 用户查找bug报告、功能请求或讨论内容
使用命令: 或
gh search issuesgh search prsbash
undefinedOpen issues with label
查找指定仓库的带bug标签的开放议题
gh search issues "is:open label:bug repo:facebook/react"
gh search issues "is:open label:bug repo:facebook/react"
PRs by author
查找指定作者的已合并拉取请求
gh search prs "author:username is:merged"
gh search prs "author:username is:merged"
Issues mentioning error
查找提及特定错误的Go语言相关议题
gh search issues '"connection refused" language:go'
undefinedgh search issues '"connection refused" language:go'
undefinedQuery Qualifiers Reference
查询限定符参考
Repo Search
仓库搜索
| Qualifier | Example | Description |
|---|---|---|
| | Star count |
| | Fork count |
| | Primary language |
| | Repository topic |
| | Exclude topic |
| | Last push date |
| | Creation date |
| | License type |
| | Archive status |
| | Visibility |
| 限定符 | 示例 | 说明 |
|---|---|---|
| | 星标数量 |
| | 复刻数量 |
| | 仓库主语言 |
| | 仓库主题 |
| | 排除指定主题 |
| | 最后推送日期 |
| | 仓库创建日期 |
| | 许可证类型 |
| | 归档状态 |
| | 仓库可见性 |
Code Search
代码搜索
| Qualifier | Example | Description |
|---|---|---|
| | File extension |
| | File path |
| | Specific repo |
| | Code language |
| | File name |
| 限定符 | 示例 | 说明 |
|---|---|---|
| | 文件扩展名 |
| | 文件路径 |
| | 指定仓库 |
| | 代码语言 |
| | 文件名 |
Common Flags
常用参数
| Flag | Description |
|---|---|
| Number of results (max 1000) |
| Sort by: stars, forks, updated, best-match |
| asc or desc |
| JSON output with specific fields |
| Open results in browser |
| 参数 | 说明 |
|---|---|
| 结果数量上限(最大1000) |
| 排序依据:stars、forks、updated、best-match |
| 排序顺序:升序(asc)或降序(desc) |
| 以JSON格式输出指定字段 |
| 在浏览器中打开结果 |
Common Use Cases
常见使用场景
"Find popular X repos"
查找热门X语言仓库
bash
gh search repos "language:X stars:>500" --sort=stars --limit=50bash
gh search repos "language:X stars:>500" --sort=stars --limit=50"How do people use library Y"
了解人们如何使用库Y
bash
gh search code "import Y" extension:ts --limit=30
gh search code "from Y import" extension:py --limit=30bash
gh search code "import Y" extension:ts --limit=30
gh search code "from Y import" extension:py --limit=30"Find repos like Z but exclude crypto"
查找类似Z的仓库但排除加密货币相关
bash
gh search repos "topic:Z -topic:cryptocurrency -topic:blockchain -topic:web3"bash
gh search repos "topic:Z -topic:cryptocurrency -topic:blockchain -topic:web3""Find recent active projects"
查找近期活跃的项目
bash
gh search repos "language:go pushed:>2024-06-01 stars:>100" --sort=updatedbash
gh search repos "language:go pushed:>2024-06-01 stars:>100" --sort=updatedTips
小贴士
- Quote the query when it contains special chars:
gh search repos "stars:>500" - Multiple languages = OR: matches either
language:rust language:go - Use for scripting:
--json--json name,url,stargazersCount - Date ranges:
pushed:2024-01-01..2024-06-01 - Numeric ranges:
stars:100..500 - Use for complex queries: When
gh apigives unexpected results, usegh search reposfor exact web paritygh api search/repositories?q=...
- 当查询包含特殊字符时,请给查询内容加引号:
gh search repos "stars:>500" - 多语言表示“或”逻辑:会匹配任意一种语言的仓库
language:rust language:go - 编写脚本时使用参数:
--json--json name,url,stargazersCount - 日期范围:
pushed:2024-01-01..2024-06-01 - 数值范围:
stars:100..500 - 复杂查询使用:当
gh api结果不符合预期时,使用gh search repos获取与网页端完全一致的结果gh api search/repositories?q=...