{"record":{"id":"317edc4e2736cb8a","repo":"benweet/stackedit","slug":"git-tree-too-big-please-remove-some-files-in-the","errorCode":null,"errorMessage":"Git tree too big. Please remove some files in the repository.","messagePattern":"Git tree too big\\. Please remove some files in the repository\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/services/providers/helpers/githubHelper.js","lineNumber":143,"sourceCode":"\n  /**\n   * https://developer.github.com/v3/repos/commits/#get-a-single-commit\n   * https://developer.github.com/v3/git/trees/#get-a-tree\n   */\n  async getTree({\n    token,\n    owner,\n    repo,\n    branch,\n  }) {\n    const { commit } = await repoRequest(token, owner, repo, {\n      url: `commits/${encodeURIComponent(branch)}`,\n    });\n    const { tree, truncated } = await repoRequest(token, owner, repo, {\n      url: `git/trees/${encodeURIComponent(commit.tree.sha)}?recursive=1`,\n    });\n    if (truncated) {\n      throw new Error('Git tree too big. Please remove some files in the repository.');\n    }\n    return tree;\n  },\n\n  /**\n   * https://developer.github.com/v3/repos/commits/#list-commits-on-a-repository\n   */\n  async getCommits({\n    token,\n    owner,\n    repo,\n    sha,\n    path,\n  }) {\n    return repoRequest(token, owner, repo, {\n      url: 'commits',\n      params: { sha, path },\n    });","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/benweet/stackedit/blob/6dce2a5e36b755a0c244522b48a06c91a2df0f59/src/services/providers/helpers/githubHelper.js#L125-L161","documentation":"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.","triggerScenarios":"`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.","commonSituations":"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.","solutions":["Remove unnecessary files/folders from the repository (build artifacts, node_modules, vendored assets) and commit.","Shallow the workspace by moving large assets out of the synced repository (LFS or separate storage).","Split the repository into smaller repositories and create separate workspaces.","Retry with a scoped tree request (non-recursive per-directory) as a custom workaround."],"exampleFix":"// before\nif (truncated) {\n  throw new Error('Git tree too big. Please remove some files in the repository.');\n}\n// after\nif (truncated) {\n  throw new Error('Git tree too big. Please remove some files in the repository (e.g. build output or large asset folders).');\n}","handlingStrategy":"validation","validationCode":"async function repoTreeCountOk(token, owner, repo, branch = 'master') {\n  const { body } = await repoRequest(token, owner, repo, { url: `git/trees/${branch}?recursive=1` });\n  return !body.truncated; // GitHub sets truncated=true when the tree exceeds limits\n}","typeGuard":"function isTruncatedTree(res) {\n  return res && res.body && res.body.truncated === true;\n}","tryCatchPattern":"try {\n  const tree = await githubHelper.getTree(token, owner, repo, branch);\n} catch (err) {\n  if (/tree too big/i.test(err.message)) {\n    adviseUserToShrinkRepo(); // clean build artifacts, use LFS, split repo\n  }\n}","preventionTips":["Keep synced repositories lean: exclude node_modules, build output, vendored assets.","Use Git LFS or external storage for large binaries.","Split very large repos into multiple workspaces/repos.","Check `truncated` on any recursive GitHub trees API response."],"tags":["github","api-limits","repository-size"],"backgroundTag":"api-response-truncated","analyzedSha":"6dce2a5e36b755a0c244522b48a06c91a2df0f59","analyzedAt":"2026-09-01T00:49:23.866Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}