Request a demo

Public dataset · Web, code and analytics

GitHub Repos in BigQuery

The github_repos dataset holds file contents, file paths, commits, languages and licenses from about 2.9 million open source GitHub repositories. The full tables run to 2.4 TiB for contents alone, so a code search can cost over $16, while the sample_* tables let you test the same SQL for cents.

bigquery-public-data.github_repos · GitHub · US · Sizes measured November 23, 2026

9tables
3.6 TiBlogical size
2,939,545,001rows
$22.61to scan every column once, on-demand

bigquery-public-data.github_repos is a snapshot of public, open source licensed repositories on GitHub: about 2.9 million of them, according to the dataset description, which gives 2022-11-27 as the last data update. The files, contents, languages and licenses tables were last modified in November 2022; commits was last modified in October 2025.

files lists every file at HEAD with its repository and path. contents stores the text of each unique file under 1 MiB, keyed by id, so you join files to contents on id to search code. commits has one row per unique commit with author, committer, message and the list of changed paths, and repo_name is an array because the same commit can appear in several repositories. languages and licenses have one row per repository.

The four sample_* tables were built in 2016 for cheap experiments: sample_repos is 400,000 popular repositories, sample_files holds their files, sample_contents is a random 10% of matching contents, and sample_commits covers six large projects (tensorflow, react, bootstrap, swift, vscode and the Linux kernel). None of the tables is partitioned or clustered.

Tables and sizes

TableRowsSizeFull scanLayout
contents
Text of unique files under 1 MiB on the HEAD branch. Join to `files` on `id`.
281,191,9772.4 TiB$15.25None
commits
Unique commits, with `repo_name` as an array of repositories that contain them.
265,419,190848 GiB$5.18None
files
Path, mode and content `id` of every file at HEAD.
2,309,424,945321 GiB$1.96None
sample_contents
Random 10% of contents for files in `sample_files` (2016).
2,905,87024.0 GiB$0.15None
sample_files
Files of the 400,000 repositories in `sample_repos` (2016).
72,879,44210.0 GiB$0.06None
sample_commits
Commits of six large repositories (2016).
672,3092.5 GiB$0.02None
languages
Languages per repository with bytes of code, from the GitHub API.
3,325,634195 MiBunder $0.01None
licenses
SPDX license code per repository.
3,325,634103 MiBunder $0.01None
sample_repos
400,000 repositories with more than 2 stars in January to May 2016.
400,00012.5 MiBunder $0.01None

Full scan = every column of the table at the on-demand list price of $6.25 per TiB, before your free TiB each month. Selecting fewer columns costs proportionally less. See BigQuery pricing.

Example queries

Most common languages by repository count

Scans 56.6 MiB · under $0.01 on-demand

language is a repeated record, so UNNEST it first. A repository counts once for every language GitHub detected in it.

SELECT
  lang.name AS language,
  COUNT(*) AS repos
FROM `bigquery-public-data.github_repos.languages`,
  UNNEST(language) AS lang
GROUP BY language
ORDER BY repos DESC
LIMIT 10;

Repositories per license

Scans 24.6 MiB · under $0.01 on-demand

One of the cheapest useful queries on the dataset: licenses is about 100 MiB.

SELECT
  license,
  COUNT(*) AS repos
FROM `bigquery-public-data.github_repos.licenses`
GROUP BY license
ORDER BY repos DESC;

Commits per year

Scans 2.0 GiB · $0.01 on-demand

Reads one nested field, committer.time_sec, out of an 848 GiB table. Git timestamps come from the committer's machine, so expect a few commits with impossible years.

SELECT
  EXTRACT(YEAR FROM TIMESTAMP_SECONDS(committer.time_sec)) AS year,
  COUNT(*) AS commits
FROM `bigquery-public-data.github_repos.commits`
GROUP BY year
ORDER BY year;

Find Python files that import the BigQuery client (full tables)

Scans 2.7 TiB · $16.82 on-demand

This is the expensive version. The LIKE on content forces a read of the whole content column, and LIMIT 100 does not stop the scan. It is more than the free monthly TiB on its own.

SELECT f.repo_name, f.path
FROM `bigquery-public-data.github_repos.files` AS f
JOIN `bigquery-public-data.github_repos.contents` AS c
  ON f.id = c.id
WHERE f.path LIKE '%.py'
  AND c.content LIKE '%from google.cloud import bigquery%'
LIMIT 100;

The same search on the sample tables

Scans 31.8 GiB · $0.19 on-demand

Identical SQL against sample_files and sample_contents. It covers only a sample of popular repositories, but it costs about 1% of the full search, which makes it the right place to debug the pattern before a single full run.

SELECT f.repo_name, f.path
FROM `bigquery-public-data.github_repos.sample_files` AS f
JOIN `bigquery-public-data.github_repos.sample_contents` AS c
  ON f.id = c.id
WHERE f.path LIKE '%.py'
  AND c.content LIKE '%from google.cloud import bigquery%'
LIMIT 100;

Querying it cheaply

  • contents.content is where the bytes are: 2.4 TiB of file text. Any LIKE, REGEXP_CONTAINS or SELECT * on contents reads all of it, whatever WHERE or LIMIT you add.
  • No table is partitioned or clustered, so filtering on repo_name or path does not cut bytes. Only the columns you select change the cost.
  • Write and test code searches on sample_files and sample_contents (about 34 GiB together), then run the full query once.
  • For repeated analysis of one slice, such as Python files only, save it once with CREATE TABLE AS SELECT and query your copy. You then pay storage for the slice instead of rescanning 2.4 TiB.
  • Set a maximum bytes billed on exploratory queries. A query over the limit fails before it runs and costs nothing (see the bytes billed limit error).

FAQ

How much does it cost to query the GitHub dataset in BigQuery?

It depends on the columns. Counting languages or licenses reads under 200 MiB, which fits easily in the free tier. Searching file text joins files and contents and reads about 2.7 TiB, roughly $16.82 at the $6.25 per TiB on-demand list price before your free TiB.

Is the github_repos dataset free?

Yes for storage: the table sits in the bigquery-public-data project and Google pays to store it. You pay for the queries you run from your own project. On-demand, the first 1 TiB scanned each month is free, then you pay per TiB scanned (see BigQuery pricing).

Is the GitHub dataset up to date?

No. The dataset description gives 2022-11-27 as the last data update, and the file and content tables have not changed since November 2022. Treat it as a historical snapshot of open source code, not a live mirror of GitHub.

Why does LIMIT not make my github_repos query cheaper?

On-demand billing counts the bytes of every column BigQuery reads, and LIMIT is applied after the scan. To pay less, select fewer columns or use the sample_* tables.

All public datasets · BigQuery cost queries · Pricing calculator

Cut BigQuery spend without guessing

Masthead attributes compute and storage cost to every project, user, pipeline and table, finds unused and dead-end tables, and shows where editions or on-demand pricing is cheaper. Mnemonic cut its BigQuery compute cost by 20% within 24 hours of onboarding.