{"record":{"id":"b080dc8fc2e51fcd","repo":"laurent22/joplin","slug":"remote-head-is-empty-make-sure-you-have-pushed-yo","errorCode":null,"errorMessage":"Remote HEAD is empty. Make sure you have pushed your changes.","messagePattern":"Remote HEAD is empty\\. Make sure you have pushed your changes\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/generator-joplin/generators/app/templates/script/publish/steps/verifyGitState.ts","lineNumber":49,"sourceCode":"\n\t// Gets the current latest local commit hash\n\tconst commitHash = await runGit('git rev-parse HEAD', 'Could not get commit hash. Ensure you are in a valid Git repository with at least one commit.');\n\tif (commitHash.length !== 40) {\n\t\tthrow new Error('Failed to extract a valid commit hash. Ensure that git is properly initialized and you have made at least one local commit (git commit) before publishing.');\n\t}\n\tlogger.success(`Commit hash extracted: ${commitHash}`);\n\n\t// check if the local project is linked to github\n\tawait runGit('git remote get-url origin', 'No remote named \\'origin\\' found. Make sure your plugin repository is hosted on GitHub.');\n\n\tconst currentBranch = await runGit('git rev-parse --abbrev-ref HEAD', 'Failed to retrieve current branch name. Ensure git is configured correctly.');\n\tif (currentBranch === 'HEAD') {\n\t\tthrow new Error('You are in a detached HEAD state. Checkout a branch (e.g. git checkout main) and push before publishing.');\n\t}\n\n\tconst remoteHeadLine = await runGit(`git ls-remote origin ${currentBranch}`, 'Could not retrieve remote HEAD. Make sure you have pushed your changes and have an internet connection.');\n\tif (!remoteHeadLine) {\n\t\tthrow new Error('Remote HEAD is empty. Make sure you have pushed your changes.');\n\t}\n\n\tconst parts = remoteHeadLine.split('\\n')[0].split(/\\s+/);\n\tif (parts.length < 2) {\n\t\tthrow new Error(`Unexpected git ls-remote output: \"${remoteHeadLine}\". Make sure your git remote and branch are configured correctly.`);\n\t}\n\n\tconst remoteHash = parts[0];\n\tif (remoteHash.length !== 40) {\n\t\tthrow new Error('Failed to extract a valid remote commit hash.');\n\t}\n\n\tif (remoteHash !== commitHash) {\n\t\tthrow new Error('Your local commit has not been pushed to GitHub. Run git push then try publishing again.');\n\t}\n\tlogger.success('Local commit is synced with remote.');\n\n\treturn commitHash;","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/laurent22/joplin/blob/2654b33620775080d1d59c552259d41e33dad3d2/packages/generator-joplin/generators/app/templates/script/publish/steps/verifyGitState.ts#L31-L67","documentation":"Thrown by verifyGitState when `git ls-remote origin <branch>` returns an empty string, meaning the remote has no ref matching the current local branch. This happens when the local branch has never been pushed, the remote branch name differs, or the remote is empty. The earlier runGit call succeeded (no error) but produced no stdout.","triggerScenarios":"Local branch was never pushed to origin; the remote branch was deleted; branch name case mismatch between local and remote; the remote 'origin' points to an empty repo; network returned empty despite exit 0 (rare).","commonSituations":"Developer committed locally and ran publish without pushing; the remote branch was renamed/deleted by a collaborator; first publish of a new plugin repo with no remote commits yet.","solutions":["Push the branch: git push -u origin <current-branch>.","Confirm the remote has the branch: git ls-remote --heads origin.","If the remote branch name differs, rename locally or push to the matching remote branch."],"exampleFix":"# before\ngit commit -m 'feat: x'\n npm run publish\n# after\ngit push -u origin main\n npm run publish","handlingStrategy":"validation","validationCode":"const remote = execSync(`git ls-remote origin ${branch}`, { encoding: 'utf8' }).trim();\nif (!remote) {\n  throw new Error('Remote has no such branch. Run: git push -u origin ' + branch);\n}","typeGuard":"function hasRemoteRef(out) { return out.trim().length > 0; }","tryCatchPattern":null,"preventionTips":["Push the branch before publishing: git push -u origin <branch>.","Verify the remote branch exists: git ls-remote --heads origin."],"tags":["plugin-publish","git","generator-joplin","remote"],"backgroundTag":null,"analyzedSha":"2654b33620775080d1d59c552259d41e33dad3d2","analyzedAt":"2026-08-12T14:26:46.263Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}