nektos/act · error
HEAD sha1 could not be resolved
Error message
HEAD sha1 could not be resolved
What it means
FindGitRevision resolves HEAD via go-git; if the HEAD reference exists but its hash is all-zero, the commit cannot be identified. A zero hash means the repository has no commits on the current branch — an 'unborn' HEAD, typical of a freshly git init'ed repo with everything still uncommitted.
Source
Thrown at pkg/common/git/git.go:77
file,
&git.PlainOpenOptions{
DetectDotGit: true,
EnableDotGitCommonDir: true,
},
)
if err != nil {
logger.WithError(err).Error("path", file, "not located inside a git repository")
return "", "", err
}
head, err := gitDir.Reference(plumbing.HEAD, true)
if err != nil {
return "", "", err
}
if head.Hash().IsZero() {
return "", "", fmt.Errorf("HEAD sha1 could not be resolved")
}
hash := head.Hash().String()
logger.Debugf("Found revision: %s", hash)
return hash[:7], strings.TrimSpace(hash), nil
}
// FindGitRef get the current git ref
func FindGitRef(ctx context.Context, file string) (string, error) {
logger := common.Logger(ctx)
logger.Debugf("Loading revision from git directory")
_, ref, err := FindGitRevision(ctx, file)
if err != nil {
return "", err
}
View on GitHub (pinned to 4f41128141)
Solutions
- Make at least one commit in the repository (git add -A && git commit -m 'init') and rerun act
- If testing workflow syntax only, bypass ref resolution features that need the SHA
- Verify with 'git rev-parse HEAD' — it should print a hash, not fail
Example fix
# before git init && cp -r myworkflow .github/workflows/ && act # zero-hash HEAD # after git init && git add -A && git commit -m 'init' && act
Defensive patterns
Strategy: validation
Validate before calling
// before running act, ensure HEAD resolves
if out, err := exec.Command("git", "-C", dir, "rev-parse", "HEAD").Output(); err != nil {
return fmt.Errorf("repo has no commits; commit first: %w", err)
} else {
log.Printf("HEAD = %s", strings.TrimSpace(string(out)))
} Prevention
- Always commit before running act in a new repo
- Script 'git rev-parse HEAD' as a preflight check
- In CI, run act only after the checkout step has fetched refs
When it happens
Trigger: Running act in a directory that is a git repo with zero commits (git init; add files; never commit), or a worktree/repo whose HEAD symbolic ref points at a branch that was never created by a commit. Any act feature needing GITHUB_SHA (action ref checkout, default ref resolution) hits it.
Common situations: Quick experiments: user inits a repo, drops a workflow in .github/workflows/, runs act before the first commit; CI checkouts of empty repos; scaffolding tools that git init but defer the first commit.
Related errors
- failed to identify reference (tag/branch) for the checked-ou
- remote '%s' exists but has no URL
- GoGitActionCache failed to open bare git %s with ref %s at %
- GoGitActionCache failed to create remote %s with ref %s at %
- GoGitActionCache failed to fetch %s with ref %s at %s: %w
AI-assisted analysis of nektos/act@4f41128141 (2026-08-15).
Data as JSON: /api/errors/0c09fc0732b1dd0d.
Report an issue: GitHub.