goreleaser/goreleaser · error

current folder is not a git repository

Error message

current folder is not a git repository

What it means

ErrNotRepository is returned when goreleaser is run in a directory that is not a git repository. The git pipe needs repository metadata (commit, tag, branch) to build version info; without a .git directory it cannot proceed. Returned from getInfo at git.go:78 (and in snapshot mode it returns a fakeInfo instead).

Source

Thrown at internal/pipe/git/errors.go:32

	return fmt.Sprintf("git is in a dirty state\nPlease check in your pipeline what can be changing the following files:\n%v\nLearn more at https://goreleaser.com/errors/dirty\n", e.status)
}

// ErrWrongRef happens when the HEAD reference is different from the tag being built.
type ErrWrongRef struct {
	commit, tag string
}

func (e ErrWrongRef) Error() string {
	return fmt.Sprintf("git tag %v was not made against commit %v", e.tag, e.commit)
}

// ErrNoTag happens if the underlying git repository doesn't contain any tags
// but no snapshot-release was requested.
var ErrNoTag = errors.New("git doesn't contain any tags - either add a tag or use --snapshot")

// ErrNotRepository happens if you try to run goreleaser against a folder
// which is not a git repository.
var ErrNotRepository = errors.New("current folder is not a git repository")

// ErrNoGit happens when git is not present in PATH.
var ErrNoGit = errors.New("git not present in PATH")

View on GitHub (pinned to f5edd73956)

Solutions

  1. Run goreleaser from the root of a valid git clone (`git init` alone also satisfies the check, though a tag is usually needed too).
  2. In CI, ensure the checkout step actually clones with git (e.g. actions/checkout, not a tarball download).
  3. If .git is excluded in Docker, copy it in or use a snapshot build with explicit version injection.

Example fix

# before (Dockerfile)
COPY --from=src /src/ /app/
RUN goreleaser build --snapshot
# after
COPY --from=src /src/.git /app/.git
COPY --from=src /src/ /app/
RUN goreleaser build --snapshot
Defensive patterns

Strategy: validation

Validate before calling

if _, err := os.Stat(".git"); err != nil {
    return errors.New("run goreleaser from inside a git repository")
}

Try / catch

err := git.Pipe{}.Run(ctx)
if errors.Is(err, git.ErrNotRepository) {
    log.Fatal("current folder is not a git repository")
}

Prevention

When it happens

Trigger: Running `goreleaser release`/`goreleaser build` outside any git repo; running inside a subdirectory extracted from a release tarball (no .git); a broken/removed .git directory.

Common situations: Running goreleaser in a Docker build context that excluded .git via .dockerignore; CI checking out a repo with git disabled; extracting source archives instead of cloning.

Related errors


AI-assisted analysis of goreleaser/goreleaser@f5edd73956 (2026-09-05). Data as JSON: /api/errors/67baee6638f35340. Report an issue: GitHub.