benweet/stackedit · error · Error

Git tree too big. Please remove some files in the repository

Error message

Git tree too big. Please remove some files in the repository.

What it means

getTree fetches the full commit tree of a GitHub repository with ?recursive=1. GitHub truncates responses for repositories whose trees exceed a size limit and sets `truncated: true`; githubHelper throws this error at src/services/providers/helpers/githubHelper.js:143 because a truncated tree would silently miss files during sync.

Source

Thrown at src/services/providers/helpers/githubHelper.js:143

  /**
   * https://developer.github.com/v3/repos/commits/#get-a-single-commit
   * https://developer.github.com/v3/git/trees/#get-a-tree
   */
  async getTree({
    token,
    owner,
    repo,
    branch,
  }) {
    const { commit } = await repoRequest(token, owner, repo, {
      url: `commits/${encodeURIComponent(branch)}`,
    });
    const { tree, truncated } = await repoRequest(token, owner, repo, {
      url: `git/trees/${encodeURIComponent(commit.tree.sha)}?recursive=1`,
    });
    if (truncated) {
      throw new Error('Git tree too big. Please remove some files in the repository.');
    }
    return tree;
  },

  /**
   * https://developer.github.com/v3/repos/commits/#list-commits-on-a-repository
   */
  async getCommits({
    token,
    owner,
    repo,
    sha,
    path,
  }) {
    return repoRequest(token, owner, repo, {
      url: 'commits',
      params: { sha, path },
    });

View on GitHub (pinned to 6dce2a5e36)

Solutions

  1. Remove unnecessary files/folders from the repository (build artifacts, node_modules, vendored assets) and commit.
  2. Shallow the workspace by moving large assets out of the synced repository (LFS or separate storage).
  3. Split the repository into smaller repositories and create separate workspaces.
  4. Retry with a scoped tree request (non-recursive per-directory) as a custom workaround.

Example fix

// before
if (truncated) {
  throw new Error('Git tree too big. Please remove some files in the repository.');
}
// after
if (truncated) {
  throw new Error('Git tree too big. Please remove some files in the repository (e.g. build output or large asset folders).');
}
Defensive patterns

Strategy: validation

Validate before calling

async function repoTreeCountOk(token, owner, repo, branch = 'master') {
  const { body } = await repoRequest(token, owner, repo, { url: `git/trees/${branch}?recursive=1` });
  return !body.truncated; // GitHub sets truncated=true when the tree exceeds limits
}

Type guard

function isTruncatedTree(res) {
  return res && res.body && res.body.truncated === true;
}

Try / catch

try {
  const tree = await githubHelper.getTree(token, owner, repo, branch);
} catch (err) {
  if (/tree too big/i.test(err.message)) {
    adviseUserToShrinkRepo(); // clean build artifacts, use LFS, split repo
  }
}

Prevention

When it happens

Trigger: `repoRequest(token, owner, repo, { url: 'git/trees/<sha>?recursive=1' })` returns body.truncated === true — the repo's recursive tree exceeded GitHub's ~100k-entry / 7MB response limit.

Common situations: Syncing a very large monorepo; a workspace repository with tens of thousands of files or heavy vendored dependencies/asset folders; repos with deep history of binary blobs counted in the tree.

Related errors


AI-assisted analysis of benweet/stackedit@6dce2a5e36 (2026-09-01). Data as JSON: /api/errors/317edc4e2736cb8a. Report an issue: GitHub.