{"record":{"id":"b4f28df370c4e36b","repo":"nektos/act","slug":"failed-to-identify-reference-tag-branch-for-the","errorCode":null,"errorMessage":"failed to identify reference (tag/branch) for the checked-out revision '%s'","messagePattern":"failed to identify reference \\(tag/branch\\) for the checked-out revision '(.+?)'","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/common/git/git.go","lineNumber":160,"sourceCode":"\t\t\treturn storer.ErrStop\n\t\t}\n\n\t\treturn nil\n\t})\n\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\t// order matters here see above comment.\n\tif refTag != \"\" {\n\t\treturn refTag, nil\n\t}\n\tif refBranch != \"\" {\n\t\treturn refBranch, nil\n\t}\n\n\treturn \"\", fmt.Errorf(\"failed to identify reference (tag/branch) for the checked-out revision '%s'\", ref)\n}\n\n// FindGithubRepo get the repo\nfunc FindGithubRepo(ctx context.Context, file, githubInstance, remoteName string) (string, error) {\n\tif remoteName == \"\" {\n\t\tremoteName = \"origin\"\n\t}\n\n\turl, err := findGitRemoteURL(ctx, file, remoteName)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\t_, slug, err := findGitSlug(url, githubInstance)\n\treturn slug, err\n}\n\nfunc findGitRemoteURL(_ context.Context, file, remoteName string) (string, error) {\n\trepo, err := git.PlainOpenWithOptions(","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/nektos/act/blob/4f411281417e88660bea1c1a1749aa71ae0bd60f/pkg/common/git/git.go#L142-L178","documentation":"FindGitRef iterates all references in the repo and tries to map the checked-out revision's hash back to a tag or branch name. If neither a tag nor any branch points at that hash, no GITHUB_REF can be synthesized and this error returns. This is expected for a detached HEAD at a commit that no ref points to (e.g. a PR merge-commit sha checked out by a bot, or a commit whose branch was deleted).","triggerScenarios":"Running act on a detached HEAD (git checkout <sha>, or a CI checkout of a merge commit) where the sha is not the tip of any branch or tag; also when .git metadata is partially present (shallow/sparse clones missing refs) so the iteration never matches.","commonSituations":"Checking out a PR merge sha locally then running act; worktrees created from commits ahead of their branches; shallow clones (depth=1) whose single fetched ref is HEAD itself; a branch deleted after the checkout.","solutions":["Checkout a named ref instead of a bare sha: git checkout main (or the tag/branch the workflow targets)","If you must test a sha, create a temporary branch at it: git switch -c test-sha <sha>","Unshallow the clone (git fetch --unshallow or --tags) so refs are visible","Pass the ref explicitly to act via --GITHUBREF or equivalent flag if your act version supports overriding"],"exampleFix":"# before (detached, no ref points at sha)\ngit checkout 1a2b3c4 && act\n\n# after\ngit switch -c tmp-test 1a2b3c4 && act","handlingStrategy":"validation","validationCode":"// preflight: ensure the checked-out sha is referrable\nout, err := exec.Command(\"git\", \"name-rev\", \"--name-only\", \"HEAD\").Output()\nname := strings.TrimSpace(string(out))\nif err != nil || name == \"undefined\" {\n    return fmt.Errorf(\"HEAD not on any branch/tag; create one: git switch -c ci-test\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run act from a named branch or tag, not a detached sha","Unshallow clones before act when refs are missing","Create a temp branch at the sha you need to test"],"tags":["git","ref","detached-head","shallow-clone","act"],"backgroundTag":null,"analyzedSha":"4f411281417e88660bea1c1a1749aa71ae0bd60f","analyzedAt":"2026-08-15T09:19:46.307Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}