{"record":{"id":"8f397ec869665a45","repo":"facebook/docusaurus","slug":"running-git-push-command-failed-does-the-github","errorCode":null,"errorMessage":"Running \"git push\" command failed. Does the GitHub user account you are using have push access to the repository?","messagePattern":"Running \"git push\" command failed\\. Does the GitHub user account you are using have push access to the repository\\?","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/docusaurus/src/commands/deploy.ts","lineNumber":286,"sourceCode":"    if (gitUserName) {\n      exec(`git config user.name ${escapeArg(gitUserName)}`, {failfast: true});\n    }\n\n    const gitUserEmail = process.env.GIT_USER_EMAIL;\n    if (gitUserEmail) {\n      exec(`git config user.email ${escapeArg(gitUserEmail)}`, {\n        failfast: true,\n      });\n    }\n\n    const commitMessage =\n      process.env.CUSTOM_COMMIT_MESSAGE ??\n      `Deploy website - based on ${currentCommit}`;\n    const commitResults = exec(\n      `git commit -m ${escapeArg(commitMessage)} --allow-empty`,\n    );\n    if (exec(`git push --force origin ${deploymentBranch}`).exitCode !== 0) {\n      throw new Error(\n        'Running \"git push\" command failed. Does the GitHub user account you are using have push access to the repository?',\n      );\n    } else if (commitResults.exitCode === 0) {\n      // The commit might return a non-zero value when site is up to date.\n      let websiteURL;\n      if (githubHost === 'github.com') {\n        websiteURL = projectName.includes('.github.io')\n          ? `https://${organizationName}.github.io/`\n          : `https://${organizationName}.github.io/${projectName}/`;\n      } else {\n        // GitHub enterprise hosting.\n        websiteURL = `https://${githubHost}/pages/${organizationName}/${projectName}/`;\n      }\n      exec(`echo \"Website is live at ${websiteURL}.\"`, {failfast: true});\n      process.exit(0);\n    }\n  };\n","sourceCodeStart":268,"sourceCodeEnd":304,"githubUrl":"https://github.com/facebook/docusaurus/blob/3f483e80e326cc646b54b83d564b3f0c4881b9a6/packages/docusaurus/src/commands/deploy.ts#L268-L304","documentation":"Thrown after `git push --force origin <deploymentBranch>` returns a non-zero exit code. The push itself failed for a git/transport/permission reason; Docusaurus surfaces this as a hint that the authenticated user probably lacks push rights to the deployment repository.","triggerScenarios":"`git push --force origin <deploymentBranch>` exits non-zero during the deploy step, e.g. bad credentials, no write access, branch protection rules, wrong SSH key, or an incorrect remote URL.","commonSituations":"Wrong `GIT_USER`; expired GitHub token; SSH key not added; deploy branch is protected (e.g. requires PR); using HTTPS deploy with a revoked PAT; cross-repo deploy where the user has no push permission on the target repo.","solutions":["Verify the deploy identity has push access: for SSH, `ssh -T git@github.com`; for HTTPS, regenerate the PAT with `repo` scope and set `GIT_USER` + use the token flow.","Check `git remote -v` on the deployment repo and confirm the URL points to a repo you can write to.","Disable or relax branch protection on the deployment branch (e.g. `gh-pages`), or push to an unprotected branch.","Re-run `docusaurus deploy` with the correct credentials; inspect the git output above the error for the real upstream message."],"exampleFix":"# before: HTTPS deploy with expired token\nGIT_USER=olduser docusaurus deploy  # push fails\n# after\ngh auth token | read TOKEN\nGIT_USER=currentUser GH_TOKEN=$TOKEN docusaurus deploy","handlingStrategy":"retry","validationCode":"import {execSync} from 'child_process';\n// pre-flight: can we even reach/write the remote?\ntry { execSync('git ls-remote --exit-code origin', {stdio: 'ignore'}); }\ncatch { throw new Error('No push access to origin — fix credentials before deploy'); }","typeGuard":null,"tryCatchPattern":"for (let attempt = 1; attempt <= 3; attempt++) {\n  try { await deploy(siteDir, cliOptions); break; }\n  catch (e) {\n    if (/git push/.test(e.message) && attempt < 3) { await sleep(2000); continue; }\n    throw e;\n  }\n}","preventionTips":["Use a long-lived deploy token (or SSH key) stored in CI secrets, not a personal account.","Disable branch protection on the deployment branch or grant bypass to the deploy identity.","Verify `git remote -v` points to a writable repo before deploy."],"tags":["deploy","github-pages","git","auth","network"],"backgroundTag":null,"analyzedSha":"3f483e80e326cc646b54b83d564b3f0c4881b9a6","analyzedAt":"2026-08-12T13:25:04.382Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}